使用maven-compiler-plugin打包lombok代码出错

错误信息

无法识别lombok生成的方法

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project lifeonline-service-blog: Compilation failure: Compilation failure: 
[ERROR] xxx/xx/XxxService.java:[31,20] 找不到符号
[ERROR]   符号:   方法 getId()

解决

配置lombok注解处理

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>21</source>
                    <target>21</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${mapstruct.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

posted @ 2023-09-28 14:55  复一日  阅读(437)  评论(0编辑  收藏  举报