0
点赞
收藏
分享

微信扫一扫

SpringBoot: @ConfigurationProperties失效/不生效问题

做个橙梦 2022-03-15 阅读 96

问题


Springboot项目中使用@ConfigurationProperties并没有生效

解决

  1. 加上@Setter (SpringBoot中的自动配置和注入基本都是使用set方法)
  2. 在main方法上加上@EnableConfigurationPropertiesScan

在使用Properties文件的方法上(不用加@component了,在Application上加了@ConfigurationPropertiesScan后会自动注入IOC)
在这里插入图片描述

主方法上:
![在这里插入图片描述](https://img-blog.csdnimg.cn/ddbc2e56cb5在这里插入图片描述
84e05986a4650f530ea94.png)

举报

相关推荐

0 条评论