Spring Boot@ConfigurationProperties无法注入application.properties中的属性配置
最小白的错误,忘记在自定义类中写setter()方法。@ConfigurationProperties(prefix=“XXX”)注解自然无法进出一个封装的类。
(如果需注入的属性配置中包含其他类的属性,别忘了也给这些类设置setter()和getter()方法,顺便@override重写ToString()以便打印输出)
手写加上SetXX()方法即可。
或者如果该属性不是复杂类型的话可以使用@Value来注入属性配置,@Value无需setter()或getter()方法