java-代码片段

Map<String,String> verityMap=new HashMap<>();


new Thread(new Runnable() {
        @SneakyThrows
        public void run() {
            
            IRS_sdkTest.sdkTest();
        }
    }).start();


List<String> testList = new ArrayList<String>();
for (int i = 0; i < 6; i++)
    testList.add("baiqi");
String tempString = StringUtils.join(testList, ";");
List<String> testList2 = Arrays.asList(tempString.split(";"));
System.out.println("tempString: " + tempString);
System.out.println("testList2: " + testList2.toString());


Integer.valueOf(str).intValue()


Date date = new Date();
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
String currrentTime=dateFormat.format(date);


时间函数
延时
Thread.currentThread().sleep(10000);


定时每分钟
upload.Scheduled.time:0 */1 * * * ?


@Scheduled(cron = "${upload.Scheduled.time}") //每10秒执行一次
public void scheduledTaskByCorn() {
    log.info("定时任务开始 ByCorn:" + new Date());
    scheduledTask();
    log.info("定时任务结束 ByCorn:" + new Date());
}


@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
 private static final boolean isWindows = System.getProperty("os.name").toLowerCase().contains("win");

 
Read timed out
@Bean
public RestTemplate restTemplate() {
    //复杂构造函数的使用
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
    requestFactory.setConnectTimeout(600000);// 设置超时
    requestFactory.setReadTimeout(600000);
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.setRequestFactory(requestFactory);
    return restTemplate;
}


jdbcTemplate
jdbcTemplate.update("UPDATE USER SET name = ? WHERE user_id = ?", new Object[] {name, id});          
jdbcTemplate.update("INSERT INTO USER VALUES(?, ?, ?, ?)", new Object[] {user.getId(), user.getName(), user.getSex(), user.getAge()});  


控制日志输出
<configuration>
    <logger name="org.apache" level="WARN" />
    <logger name="httpclient" level="WARN" />
</configuration>


查找配置文件路径
ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource();
String ApplicationHomePath = jarFile.getParent();
System.out.println("ApplicationHomePath"+ApplicationHomePath);

String studentPathC1=Thread.currentThread().getContextClassLoader().getResource(fileName).getPath();
System.out.println("c1 path: "+studentPathC1);

File fileStudent = new File(studentPathC1);
if(!fileStudent.exists()){
    fileStudent = new File(ApplicationHomePath+"\\classes\\"+fileName);
}



//System.loadLibrary("libJavaForJniDemo");
// System.load("libJavaForJniDemo.dll");


elastticSearch参考
Node.js安装及环境配置之Windows篇
windows下安装ElasticSearch5.X head插件
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值