Maven 打包报错 Couldn't retrieve @Mapper annotation
Maven Lombok MapStruct About 2,422 words错误信息
Maven
打包mvn clean package
时会抛出以下错误
Couldn't retrieve @Mapper annotation
原因
pom.xml
中父``pom或其他依赖中存在低版本的MapStruct
。可通过Maven Dependency
依赖分析查看MapStruct
版本。
解决方法
exclude
排除不同版本,使用相同版本的MapStruct
。
plugin pom
注意:Lombok
版本大于1.18.16
时,需要添加lombok-mapstruct-binding
。
lombok<1.18.16
时:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
lombok>
1.18.16`时:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
参考
Views: 5,715 · Posted: 2022-07-20
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...