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'