使用 gradle 的 bootJar 命令打包时报错

gradle + lombok,测试一切正常,使用 bootJar 命令打包时,报错:

> Task :compileJava
D:\IdeaProjects\xxx\src\main\java\xxx\FeignInterceptor.java:30: 错误: 找不到符号
        log.info("FeignInterceptor 拦截器生效");
        ^
  符号:   变量 log

D:\IdeaProjects\xxx\src\main\java\xxx\BusinessInfoService.java:105: 错误: 找不到符号
        businessInfo.setTitle("标题");
                    ^
  符号:   方法 setTitle(String)
  位置: 类型为BusinessInfo的变量 businessInfo
  
D:\IdeaProjects\xxx\src\main\java\xxx\service\UserService.java:42: 错误: 找不到符号
        return userDTO.getId();
                      ^
  符号:   方法 getId()
  位置: 类型为UserDTO的变量 userDTO

...

注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
86 个错误

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s 

解决方法:

compile 'org.projectlombok:lombok'

改成:

compile 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

如果还是不行,试试加上版本号:

compile 'org.projectlombok:lombok:1.18.2'
annotationProcessor 'org.projectlombok:lombok:1.18.2'

gradle项目使用lombok,打包出现getter setter无法找到

posted @ 2020-11-21 17:54  唯学而知  阅读(2362)  评论(0编辑  收藏  举报