spring boot 读取配置文件问题,不能使用@Autowired
来源:互联网 发布:照片尺寸修改软件 编辑:程序博客网 时间:2024/06/08 13:09
1.属性文件类
@ConfigurationProperties(prefix = "xxx.elklog")public class ElkLogConfig { private String appName; private String instanceID; private String pointcutCtrl; private String pointcutDao; private String pointcutService;
2.配置类
@Configuration@EnableConfigurationProperties(ElkLogConfig.class)public class ElkLogConfiguration { private ElkLogConfig elkLogConfig; public ElkLogConfiguration(ElkLogConfig elkLogConfig) { this.elkLogConfig = elkLogConfig; }
application.yml
xxx.elklog: appName: app-demo instanceID: 1002
解决使用
@Autowired
private ElkLogConfig elkLogConfig;
elkLogConfig这个变量为空的问题。使用构造函数可以解决。
阅读全文
0 0
- spring boot 读取配置文件问题,不能使用@Autowired
- Spring boot读取配置文件
- spring-boot 配置文件读取
- Spring boot 配置文件读取
- spring boot 读取配置文件
- spring boot mybatis 读取配置文件
- Spring boot读取配置文件总结
- spring boot mybatis 读取配置文件
- spring-boot中的读取配置文件
- Spring boot 读取配置文件——@Value的使用
- Spring boot中filter类不能注入@Autowired变量
- spring-boot读取props和yml配置文件
- spring-boot读取props和yml配置文件
- spring-boot读取props和yml配置文件
- spring-boot读取props和yml配置文件
- Spring boot之读取自定义配置文件
- Spring-boot读取多个配置文件
- spring-boot读取props和yml配置文件
- Java经典教程
- ccf认证最优灌溉
- ajax上传form表单数据
- 设计模式-适配器模式
- 一个 Linux 上分析死锁的简单方法
- spring boot 读取配置文件问题,不能使用@Autowired
- iOS TableVew 侧滑效果~ OC语言~demo
- c#类
- 反射第五步 : 通过反射获取某一个类的字段值,并设置字段值 (很少用)
- 如何将BufferedImage转换成字节数组?
- 普通用户授予root权限
- linux上传文件 rz命令 提示command not found 解决方法
- Swift
- qt压缩文件