讀取配置文件

1.配置文件redis

獲取配置文件類app

@Data
@Component
@ConfigurationProperties(prefix = "test.setting")
public class CommonConfig {
    private String str;
    private List<Integer> list;
    private List<ConfigEntity> configEntityList;
}

 application.properties文件this

test.setting.str = "this is a String Type in CommonConfig"
test.setting.list[0] = 1
test.setting.list[1] = 2
test.setting.list[2] = 3
test.setting.configEntityList[0].id = "testConfigEntityId-0"
test.setting.configEntityList[0].content = "testConfigEntityContent-0"
test.setting.configEntityList[1].id = "testConfigEntityId-1"
test.setting.configEntityList[1].content = "testConfigEntityContent-1"

 在使用類中自動裝配spa

@Autowired
private CommonConfig commonConfig;

 2.定時任務it

@Scheduled(cron = "${taskTime.redis}")

配置文件io

taskTime.redis=0 0/1 * * * ?
相關文章
相關標籤/搜索