pom.xml文件中加入spring-boot-configuration-processor依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
idea启用enable annotation processing
编写了正确的属性配置类
package com.pzy.component.webstarter.support.configuration;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @author pzy
* @date 2018/11/18
*/
@ConfigurationProperties(prefix = "component.web", ignoreInvalidFields = true)
public class WebStarterProperties {
private GlobalExceptionProperties globalException;
public GlobalExceptionProperties getGlobalException() {
return globalException;
}
public void setGlobalException(GlobalExceptionProperties globalException) {
this.globalException = globalException;
}
}
项目pom文件,编译插件配置 (重点)
<!-- Compiler 插件, 设定 JDK 版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<showWarnings>true</showWarnings>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring-boot.version}</version>
</path>
</annotationProcessorPaths>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
重新编译项目