一般情况下,java springboot读取yml文件的方法
1 写yml文件
2 写一个配置相关的类
3 启动类上加标签
代码如下
文件 XXX.yml 只是举例 与实际项目无关
index:
indexFileRootPath: C:\Users\Administrator\Desktop\data\
indexFileName: videoInfo.txt
# 表示定时任务的字符串
cronString: 0 45 3-23 * * ?
indexStartDay: 20181211
@Data
@ConfigurationProperties("index")
public class VideoIndexProperties {
/**
* 首页文件根路径
*/
private String indexFileRootPath;
/**
* 存储视频首页信息的文件名
*/
private String indexFileName;
/**
* 表示定时任务的字符串
*/
private String cronString;
/**
* 没有任务时开始入库的日期
*/
private int indexStartDay;
}
/**
* 启动类
* @author szb
*/
@SpringBootApplication
@EnableConfigurationProperties(VideoIndexProperties.class)
@EnableScheduling
public class TestApplication {
public static void main