Building with Lombok's @Slf4j and Eclipse: Cannot find symbol log

后端 未结 5 886
轮回少年
轮回少年 2020-12-18 18:22

I have the lombok plugin in Eclipse and enabled annotation processing in Eclipse under java compiler, but still it is unable to recognize the log statements when I use @Slf4

5条回答
  •  轮回少年
    2020-12-18 18:42

    I also faced the similar issue on log and @Slf4j on my STS environment. To resolve this, here is what I did on spring tool suite (sts-4.4.0.RELEASE) and lombok-1.18.10.jar (current latest version available in mavenrepository).

    1. If having maven project, ensure lombok dependency added to it. Else you need manually add the jar to your project classpath.

      org.projectlombok lombok 1.18.10 provided

    2. Clean build the maven application. This will download lombok jar in your .m2 location by default from maven repository. The path would be org\projectlombok\lombok\1.18.10\

    3. Now open command prompt and navigate to the lombok path and execute command java -jar lombok-1.18.10.jar

      C:\xxx\xxx\org\projectlombok\lombok\1.18.10>java -jar lombok-1.18.10.jar

    4. Opens up lombok dialog box. If see message Can't find IDE Click Specify location... Provide the path to your STS root location

      My case it is C:\apps\sts-4.4.0.RELEASE\SpringToolSuite.exe

      Install/Update

    5. Install successful Click Quit Installer

    6. Now in explorer navigate to your STS root path. C:\apps\sts-4.4.0.RELEASE\ We see lombok.jar placed in the sts root path Now edit in notepad SpringToolSuite4.ini file We see following appended at the end

      -javaagent:C:\apps\sts-4.4.0.RELEASE\lombok.jar

    7. Start STS using SpringToolSuite4.exe Clean, rebuild your project.

提交回复
热议问题