Lombok with Spring Tool Suite 4

青春壹個敷衍的年華 提交于 2020-01-12 03:52:32

问题


I've recently installed the new Spring Tool Suite 4 in macOS High Sierra but when I tried to run Lombok's installation it wouldn't find my STS installation,

I followed this steps for manual installation (adding -javaagent to the ini file) but with no luck: https://www.edvpfau.de/sts-spring-tool-suite-4-mit-lombok/.

Any idea?


回答1:


I did install Lombok in Spring Tool Suite 4 just some days ago for Mac and Windows. And none problems.

One:

Execute java -jar lombok.jar

  • Note: normally or by default, it does not find the installer, it is the common scenario in my experience.

Two:

Press the Specify Location button.

  • Note: for Mac, go to the Contents directory within the .app file and find the STS.ini file, it could be SpringToolSuite4.ini too.

Conclusion: therefore for any OS, the goal is find the unique file with the .ini extension

Normally I do this with the IDE closed.




回答2:


Although this might be late, but it can be of help for others just experiencing this. Bellow is how I solved this issue

STEP 1

Find lombok in your project maven directory -> Right click -> Run As -> Java Application

STEP 2 Click on Specify Location button to choose the path where STS is installed

STEP 3 Go to Application/Contents/Eclipse/SpringToolSuit4.ini Then click on Install -> Quick Installer

STEP 4 Restart STS you good to go




回答3:


I renamed SpringToolSuite4.exe and SpringToolSuite4.ini to STS.exe and STS.ini. Then used lombok installer's Specify Location to find them. After lombok installed, I renamed those files back to their original names.




回答4:


Just to add to M. Jordan's and prodigy's answer, please be sure to give execute permission to lombok.jar

(After you follow the above-mentioned step) Open terminal and change directory to the content of SpringToolSuite.app

cd /Applications/SpringToolSuite4.app/Contents/Eclipse

Then check whether execute permission is available to lombok.jar

ls -al

If you see -rw-r--r-- it means you need to give execute permission

chmod +x lombok.jar

alternatively you could also do

chmod +x /Applications/SpringToolSuite4.app/Contents/Eclipse/lombok.jar

Then restart STS




回答5:


In my case, Lombok 1.16 could not locate STS 4 installation even after pointing to it manually. Worked only after I tried with updated Lombok version - Lombok 1.18.




回答6:


None of the steps worked for me as the file dialog box won't even let me select the directory containing the SpringToolSuite4.ini

So I did the following:

  1. Get lombok-<version>.jar from either your ~/.m2/repository/org/projectlombok/lombok/<latest-version>/ If not available you can get it from mvn repository: https://mvnrepository.com/artifact/org.projectlombok/lombok/1.18.6

  2. copy the lombok-<version>.jar to /Applications/SpringToolSuite4.app/Contents/Eclipse as lombok.jar

    cp /path/to/lombok.jar /Applications/SpringToolSuite4.app/Contents/Eclipse/
    
  3. Edit the file: /Applications/SpringToolSuite4.app/Contents/Eclipse/SpringToolSuite4.ini inside the directory to add this last line:

    -javaagent:/Applications/SpringToolSuite4.app/Contents/Eclipse/lombok.jar
    
  4. Open your project in eclipse. Right click on Maven -> update project. Follow similar step if you're using another build tool (like Gradle)




回答7:


I'll show you how to completely install lombok into Spring Tool Suite 4 or latest version. First go to your project pom.xml file and add this dependency on dependencies section.

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <scope>provided</scope>
</dependency>

Go to your project root folder on your IDE and click the right button on it. Select like below:

And make sure, checked Force Update of Snapshots/Releases. Click Ok to download and update dependencies.

After finishing all task. Go to project Maven Dependencies and find lombok.jar file (>Maven Dependencies >lombok.jar). Right click on lombok jar. Go to Run As Java Application.

It will open lombok installer window and click ok. Then click Specify Location button.

Select the location where your STS bundle was installed. If it is selected properly then it will checked STS.exe, like below:

Then click install/update button. Finally lombok will be installed successfully.

Hopefully it helps you. Thanks.




回答8:


I faced same issue with for Spring tool suite 4

Solution

  1. Close running STS.

  2. Open terminal

  3. Go to ~/.m2/repository/org/projectlombok/lombok/version

  4. Run java -jar lombok-version.jar Pop window will come.
  5. If it does not pick up the STS itself. Then chose specify location Choose SpringToolSuite4.ini at ⁨Applications⁩ ▸ ⁨SpringToolSuite4⁩ ▸ ⁨Contents⁩ ▸ ⁨Eclipse⁩ .
  6. Click install
  7. After this Starts Spring tool suite and clean project.



回答9:


the easiest way you can do is that by running the following command on command prompt

java -jar (jar location/lombok.1.8.1.jar) install (the path where you installed Spring tool suite(STS))

for example:

java -jar C:\Users\karthick\.m2\repository\org\projectlombok\lombok\1.18.8\lombok-1.18.8.jar install D:\STS_Tool\spring-tool-suite-4-4.1.2.RELEASE-e4.10.0-win32.win32.x86_64\sts-4.1.2.RELEASE

after that, you have to restart the tool.



来源:https://stackoverflow.com/questions/52780535/lombok-with-spring-tool-suite-4

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