Lombok and STS issue - Method undefined

旧街凉风 提交于 2019-12-04 19:13:03

问题


I have STS versioned 3.6.3.SR1 that's based on Eclipse Luna 4.4.1.

I have did the following steps:

1) Donwload and run the lombak runnable jar and gave the path of my STS. 2) I verified the entries of vmargs, but was missing Xbootclasspath and added it to have like,

-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Dorg.eclipse.swt.browser.IEVersion=10001
-Xms512m
-Xmx1024m
-javaagent:C:\tools\Lombok\lombok.jar
-Xbootclasspath/a:C:\tools\Lombok\lombok.jar

3) I have exit and opened the STS both from shortcut as well as the absoulte location of the STS.exe

4) I verified the outline of my java classes that are annotated with @Data and other lombak annotations. I can see the getters and setters generated. Even Auto assist displays the method.

5) I did Maven -> Update Project and even did a Project Clean

6) COnfirmed that the lombak is installed as well from the About STS from Help.

Even after all the above activites, there are lots of compiler issues that complains undefined method getXXX() and setXXX() on all @Data or @Getter or @Setter annotations.

Maven build runs sucessful and the runtime behavior is fine as the complied class seems to have the getters and setters.

Intelli J seems to have no porblem with this as other developers are able to use the library.

My pom has the following entry as well:

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.4</version>
</dependency>

How do I resolve?

P.S : I downloaded Eclipse Kepler build on top of STS to enable JBoss Fuse Tooling.


回答1:


I had a similar problem which was resolved by changing the scope of the lobak dependency in the pom.xml file.

Originally the scope was "provided" and I believe I saw all the strange behaviors you described. For instance, the context-sensitive code completion pulldown included the getter and setter methods. When I chose a getter method from the pulldown the method was inserted into the source correctly. After insertion of the getter method STS marked the method invocation as a compilation error because it thought the method did not exist.

After removing the "provided" scope from the lombok dependency STS worked correctly and the getter/setter methods could be added to code, the code could be compiled/packaged and executed. Execution of the getter/setter methods worked.




回答2:


I added -Xbootclasspath/a:lombok.jar like naga1990 mentioned, however it still didn't solve the issue. After starting STS with -clean it did work.




回答3:


@Karthik R, thanks for your post. The following helped me solve the issue

  1. Go to https://projectlombok.org/ and download and double-click the jar and install in your IDE
  2. After that open the .ini file and see if it has javaagent and Xbootclasspath variables.

In my case, Xbootclasspath was missing and when I added that It worked


-Xbootclasspath/a:PATH_To_lambok.jar



回答4:


If you already tried other methods but it still doesn't work, you can try this:

If your project is Maven-based project, STS configured it as AspectJ Capability which will conflict with Lombok.

To solve it, remove Aspects Capability by Right-click the project -> AspectJ Tools -> Remove AspectJ Capability. Hope this will work.




回答5:


I solved it as follows... 1. downloaded UI Swing application of lombok ... namely lombok.jar 2. started it and entered path of sts manually till sts.exe, i.e. complete folder which contains sts.exe 3. clicked on update/install 4. while doing all above 3 steps, make sure that sts is not running at all. 5. start sts 6. clean build the project.




回答6:


This if for eclipse/STS 1. Close your sdk 2. download lombok jar 3. double click it or run it with java.exe 4. Make sure below line should get added in .ini file -javaagent:\lombok.jar 5. add below line if missing add yourself -Xbootclasspath/\lombok.jar 6. Open your sdk. Go to Help->About. You should see below line "Lombok v1.18.6 "Envious Ferret" is installed. https://projectlombok.org/" 7. Clean your project. 8. Build it again.




回答7:


Try to close your project, open it again and check. It worked for me.



来源:https://stackoverflow.com/questions/30478397/lombok-and-sts-issue-method-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!