@ConfigurationProperties失效的几种情况看看你是那种


1:yml文件换成properties文件

2:pom.xml添加

<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-configuration-processorartifactId>
<optional>trueoptional>
dependency>

3:添加插件

<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
plugin>

4:启动类添加@EnableConfigurationProperties({MailProperties.class})

 

相关