栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

java-代码片段

java-代码片段

Map verityMap=new HashMap<>();


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


List testList = new ArrayList();
for (int i = 0; i < 6; i++)
    testList.add("baiqi");
String tempString = StringUtils.join(testList, ";");
List 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()});  


控制日志输出

    
    



查找配置文件路径
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插件
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/278357.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号