public static void main(String[] args) {
SpringApplication.run(vmscronApp.class, args);
// 根据名称读取配置文件(资源文件)
ResourceBundle resource = ResourceBundle.getBundle("application");
// 根据key读取value,指定编码防止中文乱码
String ip = new String(resource.getString("engine.ip").trim().getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
String port = new String(resource.getString("engine.port").trim().getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
String startCron = new String(resource.getString("cron.start").trim().getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
String stopCron = new String(resource.getString("cron.stop").trim().getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
log.info("\n----------------------云桌面定时器-----------------------\n" +
"ovirt-engine ip:" + ip + "\n" +
"ovirt-engine port:" + port + "\n" +
"开机时间:" + startCron + "\n" +
"关机时间:" + stopCron + "\n" +
"----------------------云桌面定时器-----------------------");
}
Springboot入口读取配置文件参数
最新推荐文章于 2023-06-05 08:12:00 发布