Spring Boot注入自定义properties文件配置
2019-12-12 本文已影响0人
架构师与哈苏
创建wzq.properties

wzq.properties注入User实体类中

@PropertySource(value = "classpath:wzq.properties",ignoreResourceNotFound = true)
classpath:wzq.properties:配置文件路
ignoreResourceNotFound :没有找到配置文件是否报错,设置true不报错
@ConfigurationProperties("wzq")
将配置文件中wzq开头的配置,安装实体类的pojo命名与配置文件对应注入值
Controller类

注入成功

这是我的公众号 有最新的it咨询,和个人工作的记录:

这是我的个人微信遇到问题欢迎,提问:

我的星球欢迎加入:

最后加上高质量的淘宝店:如有质量问题随时滴滴我,童叟无欺!
