读取配置文件

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 * * * ?
相关文章
相关标签/搜索