Java 如何在eclipse luna中配置lombok

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22310414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 14:52:01  来源:igfitidea点击:

how to configure lombok in eclipse luna

javaeclipsemavenlombok

提问by alokj

I configure lombok in eclipse Luna with Maven. Annotation is added properly, but no getter and setter are generated.

我使用 Maven 在 eclipse Luna 中配置 lombok。正确添加了注释,但没有生成 getter 和 setter。

eclipse.ini

eclipse.ini

`-vm E:\Program Files\Java\jdk1.7.0_60\bin`
`-vmargs`
`-Dosgi.requiredJavaVersion=1.7`
`-javaagent:F:\Tools\Java Lib\Lombok\lombok.jar`
`-Xbootclasspath/a:F:\Tools\Java Lib\Lombok\lombok.jar`
`-Xms40m`
`-Xmx512m`

回答by Roel Spilker

Disclosure: I am one of the lombok developers. I might be biased :-)

披露:我是龙目岛的开发人员之一。我可能有偏见:-)

I strongly suggest installing Lombok via executing the lombok jar: java -jar lombok.jarThe spaces in the path might be a problem.

我强烈建议通过执行 lombok jar 来安装 Lombok:java -jar lombok.jar路径中的空格可能有问题。

Also, you'll need to use lombok version 1.14.8 (or higher) to have Luna support.

此外,您需要使用 lombok 版本 1.14.8(或更高版本)才能获得 Luna 支持。

Please check in the About Eclipse screen if lombok is installed correctly.

如果 lombok 安装正确,请检查关于 Eclipse 屏幕。

See also Cannot make Project Lombok work on Eclipse (Helios)

另请参阅无法使 Project Lombok 在 Eclipse (Helios) 上工作

回答by Jason

if you're on windows, make sure you 'unblock' the lombok.jar before you install it. if you don't do this, it will install but it wont work.

如果您使用的是 Windows,请确保在安装之前“解锁”lombok.jar。如果你不这样做,它会安装,但它不会工作。

回答by Suresh Kumar Pathak

For Integrattion with ECLIPSE LUNA in Windows 7 please foollow the below steps:

要在 Windows 7 中与 ECLIPSE LUNA 集成,请遵循以下步骤:

  • Download the jar -> lombok-1.14.6.jar.
  • Using command prompt go to java installed directory and type

    java -jar ${your_jar_path}\lombok-1.14.6.jar.
    

    Here ${your_jar_path} is your lombok-1.14.6.jar jar store directory.

  • After this it will prompt for Eclipse already installed in your system and you need to select where you want to integrate.
  • After this you need to open eclipse.ini file and make entry below

    -vmargs
    

    as

    -Xbootclasspath/a:lombok.jar
    -javaagent:lombok.jar
    
  • Start your eclipse now and create a Maven project and make entry in pom.xml as mentioned below:

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.14.6</version>
        <scope>provided</scope>
    </dependency>
    
  • 下载 jar -> lombok-1.14.6.jar。
  • 使用命令提示符转到 java 安装目录并键入

    java -jar ${your_jar_path}\lombok-1.14.6.jar.
    

    这里 ${your_jar_path} 是你的 lombok-1.14.6.jar jar 存储目录。

  • 在此之后,它会提示您的系统中已经安装了 Eclipse,您需要选择要集成的位置。
  • 在此之后,您需要打开 eclipse.ini 文件并在下面输入

    -vmargs
    

    作为

    -Xbootclasspath/a:lombok.jar
    -javaagent:lombok.jar
    
  • 现在启动你的 Eclipse 并创建一个 Maven 项目并在 pom.xml 中输入如下所述:

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

After this your are ready to write your code and check it. Without @DATA annotation it looks like: enter image description hereWith @DATA annotation it looks like: enter image description here

在此之后,您就可以编写代码并进行检查了。没有@DATA 注释,它看起来像: 在此处输入图片说明有了@DATA 注释,它看起来像: 在此处输入图片说明

An example i ran the command

我运行命令的一个例子

C:\Program Files\Java\jdk1.7.0_75>java -jar C:\Users\Shareef-VM.m2\repository\o rg\projectlombok\lombok\1.14.8\lombok-1.14.8.jar

C:\Program Files\Java\jdk1.7.0_75>java -jar C:\Users\Shareef-VM.m2\repository\o rg\projectlombok\lombok\1.14.8\lombok-1.14.8.jar

回答by MelroyD

If you are in Windows, please select "run as administrator" for the command prompt for executing the java app (ie: for executing java -jar ${your_jar_path}\lombok-1.14.6.jar).

如果您使用的是 Windows,请在命令提示符处选择“以管理员身份运行”以执行 java 应用程序(即:用于执行 java -jar ${your_jar_path}\lombok-1.14.6.jar)。

回答by Gang Fan

I have met with the exact same problem. And it turns out that the configuration file generated by gradle asks for java1.7.
While my system has java1.8 installed.

我遇到了完全相同的问题。而且原来gradle生成的配置文件要求java1.7。
虽然我的系统安装了 java1.8。

After modifying the compiler compliance level to 1.8. All things are working as expected.

将编译器合规级别修改为 1.8 后。一切都按预期工作。

回答by user1648825

It began to work only after

之后才开始工作

eclipse -clean.

日食 - 干净

And I have to launch it so each time. -cleanin eclipse.ini doesn't help.

我每次都必须启动它。-clean在 eclipse.ini 中没有帮助。

Other solutions weren't helpful too.

其他解决方案也没有帮助。

回答by Basil Benny

Just remove the 'F:\' from -javaagent

只需从 -javaagent 中删除 'F:\'

-vm E:\Program Files\Java\jdk1.7.0_60\bin

-vm E:\Program Files\Java\jdk1.7.0_60\bin

-vmargs

-vmargs

-Dosgi.requiredJavaVersion=1.7

-Dosgi.requiredJavaVersion=1.7

-javaagent:\Tools\Java Lib\Lombok\lombok.jar

-javaagent:\Tools\Java Lib\Lombok\lombok.jar

-Xbootclasspath/a:F:\Tools\Java Lib\Lombok\lombok.jar

-Xbootclasspath/a:F:\Tools\Java Lib\Lombok\lombok.jar

-Xms40m

-Xms40m

-Xmx512m

-Xmx512m

回答by Ash_P

Here is the complete steps to be followed, you wont see any issues.

这是要遵循的完整步骤,您不会看到任何问题。

1. Download Lombok Jar File -Its better to have a Maven/Gradle dependency in your application. The maven depency can be found here: https://mvnrepository.com/artifact/org.projectlombok/lombok

1. 下载 Lombok Jar 文件 -最好在您的应用程序中有 Maven/Gradle 依赖项。Maven 依赖可以在这里找到:https://mvnrepository.com/artifact/org.projectlombok/lombok

2. Start Lombok Installation -
Once the jar downloaded in Local repository, goto the jar location from command prompt and run the following command java -jar lombok-1.16.18.jarand we should be greeted by Lombok installation window provided by lombok like this.

2. 开始安装 Lombok -
在本地存储库中下载 jar 后,从命令提示符转到 jar 位置并运行以下命令java -jar lombok-1.16.18.jar,我们应该会看到 lombok 提供的 Lombok 安装窗口,如下所示。

3. Give Lombok Install Path -Now click on the “Specify Location”button and locate the eclipse.exe/STS.exepath under eclipse installation folder like this.

3. 提供 Lombok 安装路径 -现在单击“Specify Location”按钮并找到eclipse.exe/STS.exeeclipse 安装文件夹下的路径,如下所示。

enter image description here

在此处输入图片说明

4. Finish Lombok Installation -Now we need to finally install this by clicking the “Install/Update”button and we should finished installing lombok in eclipse and we are ready to use its hidden power. Final screen will look like,

4. 完成 Lombok 安装 -现在我们需要通过单击“安装/更新”按钮来最终安装它,我们应该在 eclipse 中完成了 lombok 的安装,我们已经准备好使用它的隐藏功能了。最终屏幕看起来像,

enter image description here

在此处输入图片说明

5. Please make sure to add below entry into the STS.inifile, if its not already there.

5. 请确保将以下条目添加到STS.ini文件中,如果它还没有的话。

-vmargs -javaagent:lombok.jar

Note: After doing all this if this doesn't worked then make sure to change the workspace and build the code again. It will work.

注意:完成所有这些后,如果这不起作用,请确保更改工作区并再次构建代码。它会起作用。

回答by John Ole Njue

After two weeks of searching and trying, the following instructions works in

经过两周的搜索和尝试,以下说明适用于

Eclipse Java EE IDE for Web Developers.

面向 Web 开发人员的 Eclipse Java EE IDE。

Version: Oxygen.3a Release (4.7.3a) Build id: 20180405-1200

版本:Oxygen.3a 发布 (4.7.3a) 版本号:20180405-1200

  1. Copy Lombok.jar to installation directory my case (/opt/eclipse-spring/)
  2. Modify eclipse.ini openFile --launcher.appendVmargs
  1. 将 Lombok.jar 复制到安装目录 my case (/opt/eclipse-spring/)
  2. 修改 eclipse.ini openFile --launcher.appendVmargs

as follows:

如下:

openFile
--launcher.appendVmargs
-vmargs
-javaagent:/opt/eclipse-spring/lombok.jar
-Dosgi.requiredJavaVersion=1.8

......

......

In build.gradle dependencies, add lombok.jar from file as follows

在 build.gradle 依赖项中,从文件中添加 lombok.jar 如下

compileOnly files('/opt/eclipse-spring/lombok.jar')

compileOnly 文件('/opt/eclipse-spring/lombok.jar')

And yippee, I have a great day coding with lombok.

还有 yippee,我在 lombok 上度过了愉快的一天。

回答by Vikram B

Step 1: Goto https://projectlombok.org/downloadand click on 1.18.2

第 1 步:转到https://projectlombok.org/download并单击 1.18.2

Step 2: Place your jar file in java installation path in my case it is C:\Program Files\Java\jdk-10.0.1\lib

第 2 步:将您的 jar 文件放在 java 安装路径中,在我的情况下它是 C:\Program Files\Java\jdk-10.0.1\lib

step 3: Open your Eclipse IDE folder where you have in your PC.

第 3 步:打开 PC 中的 Eclipse IDE 文件夹。

Step 4: Add the place where I added then open your IDE it will open without any errors.

第 4 步:添加我添加的地方,然后打开您的 IDE,它将打开而不会出现任何错误。

-startup
plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.700.v20180518-1200
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-javaagent:C:\Program Files\Java\jdk-10.0.1\lib\lombok.jar
-Xbootclasspath/a:C:\Program Files\Java\jdk-10.0.1\lib\lombok.jar
[email protected]/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=1.8
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx1024m
--add-modules=ALL-SYSTEM