1、从启动类删除@EnableConfigurationProperties注解
2、在注解的类上加上@Component
3、加上@PropertySource("classpath:xxx.properties")注解

本文介绍如何在Spring Boot项目中正确使用配置属性注解。包括从启动类删除@EnableConfigurationProperties,在类上添加@Component和@PropertySource注解的方法。
1、从启动类删除@EnableConfigurationProperties注解
2、在注解的类上加上@Component
3、加上@PropertySource("classpath:xxx.properties")注解


被折叠的 条评论
为什么被折叠?