2019 年文章归档
共 11 篇文章
spring boot项目正确读取项目资源文件
maven项目:资源文件放在src/main/resources IDE调试时未打包:资源文件放在target/classes中 非spring boot的瘦包,资源文件放在xxx.jar包的根下。 spring boot肥包,资源文件放在xxx.jar包下的BOOT-INF\classes\中。 org.springframework.core.io.ClassPathResource 支持IDE时的未打包资源,和瘦包。不支持Spring boot可运行的肥包。 org.springframework.core.io.DefaultResourceLoader 支持IDE时的未打包资源,和…
2019-11-22 17:54
MySQL show processlist过滤
show full processlist; #根据USER过滤 select * from information_schema.processlist where USER="UserName" order by HOST; #根据HOST IP过滤,由于HOST包括Port,需要提取IP select * from information_schema.processlist where LEFT(HOST, instr(HOST, ':')-1)='192.168.10.1' order by HOST; #根据IP统计连接数 select LEFT(HOST, instr(HOST…
2019-11-08 14:19
时间间隔格式化
public class DurationFormat { public static String format(long durationMilliseconds) { // milliseconds long iterator = durationMilliseconds; long milliseconds = iterator % 1000; // seconds iterator /= 1000; long seconds = iterator % 60; // minutes iterator /= 60; long minutes = iterator % 60; // ho…
2019-11-07 09:19
UUID高效去除短横线
import java.util.UUID; public class UUIDUtil { /** * 1111 * * all 1 in 16 hexadecimal */ private static final long hexMod = 15L; /** * All possible chars for representing a number as a hex String */ private static final char[] digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', …
2019-09-18 14:00
java8 使用parallelStream线程安全地收集数据
http://zhk.me/1281.html 以下我们常用的数据结构,都是线程不安全的。 ArrayList, LinkedList HashMap, LinkedHashMap, TreeMap HashSet, LinkedHashSet, TreeSet StringBuilder parallelStream是以多线程的方式,执行定义的代码块。因为是多线程,所以在代码块里操作线程不安全的Collection,就会引发Concurrency问题。 List<String> results = Lists.newArrayList(); sources.parallelStream()…
2019-07-01 17:23
parallelStream concurrent secure
About parallelStream collect results. Please Use the collect method. The collect method is concurrent secure. import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Link…
2019-07-01 17:15
org.springframework.scheduling.annotation.@Async使用的线程池
org.springframework.scheduling.annotation.@Async使用的线程池 org.springframework.aop.interceptor.AsyncExecutionInterceptor.invoke(final MethodInvocation invocation) 102 ->107 对@Async注解的方法代为执行。 org.springframework.aop.interceptor.AsyncExecutionAspectSupport.determineAsyncExecutor(Method method) 149 →162 o…
2019-05-31 15:04 · 源码笔记
org.springframework.scheduling.annotation.@Scheduled 使用的线程池
org.springframework.scheduling.annotation.@Scheduled 使用的线程池 org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor#finishRegistration() 216→235,240,256,261 org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor#resolveSchedulerBean(BeanFactory, Class …
2019-05-31 15:01 · 源码笔记
bat 清理 maven 仓库未成功下载的文件
@echo off if "%1"=="" ( set path= D:\\_m2 ) else ( set path= %1 ) echo start clear mvn %path% rem 过滤出(*.sha1-in-progress为后缀的文件 for /r %path% %%i in (*.sha1-in-progress) do ( echo %%i rem 删除文件所在目录 rd /s/q %%i\.. ) echo finish clear mvn %path% pause
2019-03-18 16:24
Eclipse使用技巧之搜索文件中的所有汉字
https://blog.csdn.net/huofenghuang188/article/details/44828675 Eclipse搜索所有汉字 项目收尾阶段,客户强力要求源码中不能出现中文,连注释也要翻译成英文的。于是就需要讲源码中的所有中文搜索出来,经过查找资料成功解决问题。 方法如下: 在eclipse里,按下ctrl + h, 弹出Search面板, 选中File Search 在Containing text中输入或,注意:包含方括号,方括号左右不可有空格。 勾选右侧Regular expression,在File name patterns 中输入搜索文件类型 *.jav…
2019-01-22 17:53
mysql运行报The server time zone value 'Öйú±ê׼ʱ¼ä'
https://www.cnblogs.com/ljy-20180122/p/9157912.html mysql运行报The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone的解决方法 话不多说,从错误即可知道是时区的错误,因此只要将时区设置为你当前系统时区即可, 因此使用root用户登录mysql,按照如下图所示操作即可。 show variables like '%time_zone%'; set global time_zone='+8:00'; 我电…
2019-01-02 15:37