mybatis X插件好用
log报错是因为没有lombok插件或者没加注解@slf4j
oracle数据库测试语句需要from
代码对齐Ctrl+shift+L
打包错误
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
</plugin>
jar包运行之后乱码 java -Dfile.encoding=utf-8 -jar
java工具类库 hutool 下载功能亲测好用
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.20</version>
</dependency>
java只保留hh:mm:ss的time格式
@JsonFormat(pattern = "HH:MM:SS",timezone = "GMT+8")
swagger报错:swagger2 Illegal DefaultValue null for parameter type integer
原因:swagger-models 1.5.20版本bug
解决方案:更换依赖版本
<!-- swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>
进度条加载页面不变,创建一个线程跳出方法,就可以看到进度条加载的画面
private ExecutorService 执行线程 = Executors.newFixedThreadPool(1);
/**
* 单击执行按钮
*/
@FXML
public void uploadAction(ActionEvent actionEvent) {
执行线程.execute(() -> {
//点击执行就清空进度条
pb1.setProgress(0);
taOutput.clear();
taOutput.setText(JSON.toJSONString("正在下载并记录,请稍后。。。"));
// List<String> listUrl = attachmentDao.getListUrl();
List<String> listUrl = new LinkedList<>();
for (int i = 0; i < 15; ++i) {
listUrl.add("aaa");
}
//需要下载的文件总数
int sum = listUrl.size();
List<String> list1 = null;
List<String> list2 = null;
List<String> list3 = null;
Map<String, Integer> map = new HashMap();
map.put("T1", 0);
map.put("T2", 0);
map.put("T3", 0);
//将一个大集合分为三个小集合,对应三个线程
if (sum % 3 == 0) {//假设a=3
list1 = listUrl.subList(0, sum / 3);//0
list2 = listUrl.subList(sum / 3, sum / 3 * 2);//1
list3 = listUrl.subList(sum / 3 * 2, sum);//2
} else if (sum % 3 == 1) {//假设a=4
list1 = listUrl.subList(0, (sum + 2) / 3); //0 1
list2 = listUrl.subList((sum + 2) / 3, (sum + 2) / 3 * 2 - 1);//2
list3 = listUrl.subList((sum + 2) / 3 * 2 - 1, sum);//3
} else if (sum % 3 == 2) {//假设a=5
list1 = listUrl.subList(0, (sum + 1) / 3); //0 1
list2 = listUrl.subList((sum + 1) / 3, (sum + 1) / 3 * 2);//2 3
list3 = listUrl.subList((sum + 1) / 3 * 2, sum);// 4
}
//开启三个线程
MyThread thread1 = new MyThread(list1, attachmentService, attachmentDao, obsAttachmentDao, map, sum);
MyThread thread2 = new MyThread(list2, attachmentService, attachmentDao, obsAttachmentDao, map, sum);
MyThread thread3 = new MyThread(list3, attachmentService, attachmentDao, obsAttachmentDao, map, sum);
thread1.setName("T1");
thread2.setName("T2");
thread3.setName("T3");
thread1.start();
thread2.start();
thread3.start();
double d = 0;
do {
int a = thread1.getMap().get("T1");
int b = thread2.getMap().get("T2");
int c = thread3.getMap().get("T3");
d = a + b + c;
System.out.println(d);
double p = d / sum;
//四舍五入
BigDecimal bg = new BigDecimal(p);
double p1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
//进度条显示
pb1.setProgress(p1);
if (p1 == 1) {
taOutput.setText(JSON.toJSONString("下载完成并已记录!"));
}
} while (d < sum);
});
}