1、pom
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.3.Final</version>
</dependency>
2、maven中配置编译的path
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
3、使用
@Mapper
public interface MapStructUtil {
MapStructUtil INSTANCE = Mappers.getMapper(MapStructUtil.class);
@BeanMapping(ignoreUnmappedSourceProperties = {"password"})
UserInfo mapUserInfoDTOToUserInfo(UserInfoDTO userInfoDTO);
}