gitweixin
  • 首页
  • 小程序代码
    • 资讯读书
    • 工具类
    • O2O
    • 地图定位
    • 社交
    • 行业软件
    • 电商类
    • 互联网类
    • 企业类
    • UI控件
  • 大数据开发
    • Hadoop
    • Spark
    • Hbase
    • Elasticsearch
    • Kafka
    • Flink
    • 数据仓库
    • 数据挖掘
    • flume
    • Kafka
    • Hive
    • shardingsphere
    • solr
  • 开发博客
    • Android
    • php
    • python
    • 运维
    • 技术架构
    • 数据库
  • 程序员网赚
  • bug清单
  • 量化投资
  • 在线查询工具
    • 去行号
    • 在线时间戳转换工具
    • 免费图片批量修改尺寸在线工具
    • SVG转JPG在线工具

springboot导出excel工具类

精品微信小程序开发门户,代码全部亲测可用

  • 首页   /  
  • 作者: east
  • ( 页面76 )
Java 3月 2,2020

springboot导出excel工具类

try{
//捕获内存缓冲区的数据,转换为字节数组
ByteArrayOutputStream out = new ByteArrayOutputStream();
workbook.write(out);
//获取内存缓冲中的数据
byte[] content = out.toByteArray();
//将字节数据转化为输入流
InputStream in = new ByteArrayInputStream(content);
//通过调用reset()方法可以重新定位
response.reset();
//JSONP 解决跨域问题
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Methods","GET,POST,PUT,DELETE,OPTIONS");
response.addHeader("Access-Control-Allow-Headers", "WWW-Authenticate,Authorization,Set-Cookie," +
"X-Requested-With,Accept-Version,Content-Length,Content-Type,Date,X-Api-Version,name");
response.addHeader("Access-Control-Allow-Credentials", "true");
// response.setContentType("application/octet-stream");
//如果文件名是英文名不需要加编码格式,如果是中文名需要添加"ios-8859-1"防止乱码
response.setHeader("Content-Disposition", "attachment;filename=" +
new String((fileName + ".xls").getBytes("gb2312"), "iso-8859-1"));
response.setHeader("Content-Length", "" + content.length);
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
BufferedInputStream bis = new BufferedInputStream(in);
BufferedOutputStream bos = new BufferedOutputStream(outputStream);
byte[] buff = new byte[8192];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))){
bos.write(buff, 0, bytesRead);
}
bis.close();
bos.close();
outputStream.flush();
outputStream.close();

}catch (IOException ex){
ex.printStackTrace();
}
作者 east
bug清单 2月 23,2020

配置nginx ssl证书问题排查

小程序的ssl证书过期了,重新生成证书,替换证书后,在小程序还提示连接超时,看网上说https不安全也有这个提示。

访问访问,果然提示证书过期了。

检查nginx配置文件

server {    
listen 80;
server_name bjubi.com;// 你的域名
rewrite ^(.*)$ https://$host$1 permanent;// 把http的域名请求转成https
}

server {
listen 443;
server_name bjubi.com; // 你的域名
  ssl on;
root /var/www/bjubi.com; // 前台文件存放文件夹,可改成别的
index index.html index.htm;// 上面配置的文件夹里面的index.html ssl_certificate cert/214292799730473.pem;// 改成你的证书的名字 ssl_certificate_key cert/214292799730473.key;// 你的证书的名字 ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
index index.html index.htm;
}
}
觉得配置没问题,继续排查


配置完成后,检查一下nginx配置文件是否可用,有successful表示可用。
$ nginx -t // 检查nginx配置文件
返回结果如下:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
觉得配置应该没问题。

为了使配置生效
nginx -s reload // 使配置生效
shell提示: nginx: [alert] kill(1617, 1) failed (3: No such process)
果然出问题了。



[root@localhost /]# whereis ngnix
ngnix:[root@localhost/]# 
[root@localhost /]# find / -name nginx 
/usr/local/src/nginx/sbin/nginx
[root@localhost /]# find / -name nginx.conf
/usr/local/nginx
/usr/local/nginx/sbin/nginx
/usr/bin/nginx
/etc/rc.d/init.d/nginx
[root@localhost /]# /usr/local/src/nginx/sbin/nginx -c nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] still could not bind()

端口被绑定了,需要先kill掉占用的线程

netstat -ntlp

shell返回结果如下:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 28256/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3301/nginx: worker
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 919/pure-ftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2565/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 3301/nginx: worker
tcp6 0 0 :::21 :::* LISTEN 919/pure-ftpd

使用命令 kill -9 3301
再制定配置 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx -s reload           
重启nginx,果然证书生效了。

作者 east
bug清单 2月 23,2020

Nginx:[emerg] unknown directive ” ” in*******

编辑 了nginx.conf 文件后保存。启动服务器后就报错

10352#3232: unknown directive “server” in /nginx-1.8.1/conf/nginx.conf:1

或Nginx:[emerg] unknown directive ” ” in*
但查看nginx.conf 却没有发现问题。
在网上查找了资料。conf文件被记事本编辑过,保存成了含[utf8 BOM] 。所以才报错的。

使用文本编辑器更改文件的编码模式,改回utf-8编码:

作者 east
spring 2月 6,2020

凯利公式源代码

凯利公式如下:

仓位 =(odds *pwin-q)/b

  odds = 赔率(赔率=期望盈利÷可能亏损=2美元盈利÷1美元亏损,赔率就是2了)

  pwin = 成功概率(抛硬币正反面都是50%的概率)

  q = 失败概率 (也就是 1-p,赌局中也是50%了 )


public class kellyUtil {

/**
* 凯利公式
* @param pwin 胜率
* @param odds 赔率
* @return
*/
public static double kelly(double pwin,double odds){
return (odds * pwin + pwin - 1)/odds;
}

public static double kellyV2(double pwin,double odds, double lossRate){
return (odds * pwin + pwin - 1)/(odds * lossRate);
}

/**
* 巴菲特版仓位管理
* @param pwin
* @return
*/
public static double buffett(double pwin){
return 2 * pwin - 1;
}

public static void main(String[] args) {
double odds = kelly(0.5, 3.0);
// double odds = kellyV2(0.5, 3.0,1.5);
System.out.println(("仓位:" + odds * 100 + "%"));
}
}
作者 east
spring 1月 14,2020

maven 增加本地libs依赖的完美方案

1、首先新建libs文件夹,把外部依赖的jar放进去。

2、在pom文件把外部依赖jar文件导进去

<dependency>
<groupId>org.codehaus.stax2</groupId>
<artifactId>stax2</artifactId>
<version>3.1.4</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/stax2-api-3.1.4.jar</systemPath>
</dependency>

其中groupId、artifactId和version都可以自己定义  scope是system,和provided类似,只是jar包本地提供,这种方式有个缺点,那就是在项目打成jar或war包的时候因为scope是system,只在编译的时候能用,install的时候不会打进去。

在pom中给spring boot的打包插件设置一下includeSystemScope参数即可?

<build>
<plugins>
<plugin>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-maven-plugin</artifactId>
 <configuration>
  <includeSystemScope>true</includeSystemScope>
 </configuration>
</plugin>
</plugins>
</build>
作者 east
bug清单 1月 13,2020

which is not functionally dependent on columns in GROUP BY clause; this is i

解决方法一:

1、运行 select @@sql_mode;

2.    把第一步中查询到的值删掉only_full_group_by,其它的 在mysql配置文件my.cnf中添加配置项:

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

3.  运行 service mysqld restart 重启mysql;

解决方法二:

改写语句列表名称需要加上:ANY_VALUE
如:SELECT ANY_VALUE(t_name),ANY_VALUE(t_time)   FROM t2 GROUP BY t_name 

作者 east
Hbase 1月 1,2020

hbase的常用操作工具类


public class HbaseUtil {

private static SimpleDateFormat parse = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

private static Configuration conf = null;

static{
setConf();
}

private static void setConf(){
conf = HBaseConfiguration.create();
String userDir = System.getProperty("user.dir") + File.separator + "conf" + File.separator;
Path hconf_path = new Path(userDir + "conf.xml");
conf.addResource(hconf_path);
}

public static Connection getConn() throws IOException {
return ConnectionFactory.createConnection(conf);
}

/**
* 该方法用于关闭表和connection的连接
*
@param table
*
@param conn
*/
private static void closeSource(Table table, Connection conn,ResultScanner scanner){
try {
if(table != null) table.close();
if (conn != null) conn.close();
if (scanner != null) scanner.close();
} catch (IOException e) {
e.printStackTrace();
}
}

/**
* 轨迹查询:根据表名 mac 起始时间 结束时间查询
*
@param tableName
*
@param mac
*
@param startTime
*
@param endTime
*
@return
* @throws IOException
*/
public static ResultScanner scan(String tableName, String mac, long startTime, long endTime) throws IOException {
Connection conn = null;
Table table = null;
ResultScanner scanner = null;
try {
conn = HbaseUtil.getConn();
table = conn.getTable(TableName.valueOf(tableName));
Scan scan = new Scan();

byte[] startRow = (mac + startTime).getBytes();
byte[] endRow = (mac + endTime).getBytes();

scan.setStartRow(startRow);
scan.setStopRow(endRow);

scanner = table.getScanner(scan);
return scanner;
}catch (Exception e){
e.printStackTrace();
}finally {
closeSource(table,conn,scanner);
}
return null;
}
}
作者 east
Hbase 1月 1,2020

如何使用hbase行键过滤器RowFilter

RowFilter是用来对rowkey进行过滤的,比较符如下:

OperatorDescription
LESS小于
LESS_OR_EQUAL小于等于
EQUAL等于
NOT_EQUAL不等于
GREATER_OR_EQUAL大于等于
GREATER大于
NO_OP排除所有

ComparatorDescription
BinaryComparator使用Bytes.compareTo()比较
BinaryPrefixComparator和BinaryComparator差不多,从前面开始比较
NullComparatorDoes not compare against an actual value but whether a given one is null, or not null.
BitComparatorPerforms a bitwise comparison, providing a BitwiseOp class with AND, OR, and XOR operators.
RegexStringComparator正则表达式
SubstringComparator把数据当成字符串,用contains()来判断

提取rowkey以01结尾数据
Filter filter = new RowFilter(CompareFilter.CompareOp.EQUAL,new RegexStringComparator(“.*01$”));

提取rowkey以包含201407的数据
Filter filter = new RowFilter(CompareFilter.CompareOp.EQUAL,new SubstringComparator(“201407”));

提取rowkey以123开头的数据
Filter filter = new RowFilter(CompareFilter.CompareOp.EQUAL,new BinaryPrefixComparator(“123”.getBytes()));


						
作者 east
Hbase 1月 1,2020

hbase的行键(rowkey)设计体会

rowkey设计有以下几个原则
1、长度越短越好 
2、唯一性 
3、散列性 

1、如果是查询某个特征值的轨迹,rowkey可以这样设计考虑

唯一标识+时间戳,这样就很快遍历(Scan)出轨迹。

2、如果经常要查询某一段时间内的所有的特征值,row就要考虑这样:

时间戳+唯一标识。

作者 east
bug清单 1月 1,2020

springboot启动feign项目报错:Service id not legal hostname

在feign项目中,定义接口调用服务Java,想当然像下面那样写,

@FeignClient(name= "/eureka_client")
public interface TestInterface {
    @GetMapping(value = "/get")
    String get();
}

出错后发现 不能加多个/,要写成@FeignClient(name= “eureka_client”)就可以了,还发现feign不支持”_“,但可以改成”–“。

作者 east
bug清单 7月 25,2019

Android Studio3.0以上版本解决不支持 lambda 表达式

当出现错误:

-source 1.7 中不支持 lambda 表达式

(请使用 -source 8 或更高版本以启用 lambda 表达式)

lambda expressions are not suported at this language level

解决方案:

app的build.gradle中需要写入

android {

compileOptions {

sourceCompatibility JavaVersion.VERSION_1_8

targetCompatibility JavaVersion.VERSION_1_8

}

}

特别注意:
3.0版本以后,AS自身就支持lambda,不用添加下面这2个,不然会出现奇怪的错误:Could not get unknown property ‘bootClasspath’ for object of type …

apply plugin: ‘me.tatarka.retrolambda’ //把这句去掉

dependencies {

classpath ‘me.tatarka:gradle-retrolambda:3.2.4’ //这句也去掉 }

作者 east
大数据开发 7月 15,2019

大数据开源项目汇总2019

电信大数据项目
以通话数据去展示如何处理并分析大数据,并最终通过图表可视化展示。

github地址:https://github.com/LittleLawson/ChinaTelecom

基于Spark的电影推荐系统

类似于国内豆瓣网站,能够在该项目-电影网站-进行电影信息浏览和查询,并且-电影网站-会根据用户的 浏览记录和用户评论,点赞(好看)等操作 给用户进行实时的电影推荐(Spark)

https://github.com/LuckyZXL2016/Movie_Recommend

大数据项目实战之新闻话题的实时统计分析

一个完整的大数据项目实战,实时|离线统计分析用户的搜索话题,并用酷炫的前端界面展示出来。所用到的框架包括:Flume+KafKa+Hbase+Hive+Spark(SQL、Structured Streaming )+Mysql+SpringMVC+Mybatis+Websocket+AugularJs+Echarts。

https://github.com/LuckyZXL2016/Movie_Recommend

基于WIFI探针的商业大数据分析技术

WIFI探针是一种可以记录附近mac地址的嗅探器,可以根据收集到的mac地址进行数据分析,获得附近的人流量、入店量、驻留时长等信息
本系统以Spark + Hadoop为核心,搭建了基于WIFI探针的大数据分析系统

https://github.com/wanghan0501/WiFiProbeAnalysis

作者 east

上一 1 … 75 76 77 … 93 下一个

关注公众号“大模型全栈程序员”回复“小程序”获取1000个小程序打包源码。回复”chatgpt”获取免注册可用chatgpt。回复“大数据”获取多本大数据电子书

标签

AIGC AI创作 bert chatgpt github GPT-3 gpt3 GTP-3 hive mysql O2O tensorflow UI控件 不含后台 交流 共享经济 出行 图像 地图定位 外卖 多媒体 娱乐 小程序 布局 带后台完整项目 开源项目 搜索 支付 效率 教育 日历 机器学习 深度学习 物流 用户系统 电商 画图 画布(canvas) 社交 签到 联网 读书 资讯 阅读 预订

官方QQ群

小程序开发群:74052405

大数据开发群: 952493060

近期文章

  • 如何在Chrome中设置启动时自动打开多个默认网页
  • spark内存溢出怎样区分是软件还是代码原因
  • MQTT完全解析和实践
  • 解决运行Selenium报错:self.driver = webdriver.Chrome(service=service) TypeError: __init__() got an unexpected keyword argument ‘service’
  • python 3.6使用mysql-connector-python报错:SyntaxError: future feature annotations is not defined
  • 详解Python当中的pip常用命令
  • AUTOSAR如何在多个供应商交付的配置中避免ARXML不兼容?
  • C++thread pool(线程池)设计应关注哪些扩展性问题?
  • 各类MCAL(Microcontroller Abstraction Layer)如何与AUTOSAR工具链解耦?
  • 如何设计AUTOSAR中的“域控制器”以支持未来扩展?

文章归档

  • 2025年8月
  • 2025年7月
  • 2025年6月
  • 2025年5月
  • 2025年4月
  • 2025年3月
  • 2025年2月
  • 2025年1月
  • 2024年12月
  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年6月
  • 2024年5月
  • 2024年4月
  • 2024年3月
  • 2023年11月
  • 2023年10月
  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年1月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年7月
  • 2018年6月

分类目录

  • Android (73)
  • bug清单 (79)
  • C++ (34)
  • Fuchsia (15)
  • php (4)
  • python (45)
  • sklearn (1)
  • 云计算 (20)
  • 人工智能 (61)
    • chatgpt (21)
      • 提示词 (6)
    • Keras (1)
    • Tensorflow (3)
    • 大模型 (1)
    • 智能体 (4)
    • 深度学习 (14)
  • 储能 (44)
  • 前端 (5)
  • 大数据开发 (493)
    • CDH (6)
    • datax (4)
    • doris (31)
    • Elasticsearch (15)
    • Flink (79)
    • flume (7)
    • Hadoop (19)
    • Hbase (23)
    • Hive (41)
    • Impala (2)
    • Java (71)
    • Kafka (10)
    • neo4j (5)
    • shardingsphere (6)
    • solr (5)
    • Spark (100)
    • spring (11)
    • 数据仓库 (9)
    • 数据挖掘 (7)
    • 海豚调度器 (10)
    • 运维 (35)
      • Docker (3)
  • 小游戏代码 (1)
  • 小程序代码 (139)
    • O2O (16)
    • UI控件 (5)
    • 互联网类 (23)
    • 企业类 (6)
    • 地图定位 (9)
    • 多媒体 (6)
    • 工具类 (25)
    • 电商类 (22)
    • 社交 (7)
    • 行业软件 (7)
    • 资讯读书 (11)
  • 嵌入式 (71)
    • autosar (63)
    • RTOS (1)
    • 总线 (1)
  • 开发博客 (16)
    • Harmony (9)
  • 技术架构 (6)
  • 数据库 (32)
    • mongodb (1)
    • mysql (13)
    • pgsql (2)
    • redis (1)
    • tdengine (4)
  • 未分类 (7)
  • 程序员网赚 (20)
    • 广告联盟 (3)
    • 私域流量 (5)
    • 自媒体 (5)
  • 量化投资 (4)
  • 面试 (14)

功能

  • 登录
  • 文章RSS
  • 评论RSS
  • WordPress.org

All Rights Reserved by Gitweixin.本站收集网友上传代码, 如有侵犯版权,请发邮件联系yiyuyos@gmail.com删除.