梅文 +在 Eclipse 中编译时出现 Delombok 问题

发布于 2024-11-18 10:39:53 字数 2844 浏览 10 评论 0原文

我在 Eclipse 中有一个使用 lombok/delombok 的 Maven 项目。

当我使用 Maven 脚本(例如 mvn clean package)从 Eclipse 构建时,一切正常。

然而,当我直接从 Eclipse 运行时(比如对我的项目进行清理/构建),我遇到了一个类路径问题,该类应该存在于 JDK 的 tools.jar 中。我尝试将tools.jar直接添加到我的项目构建路径中,但没有成功。

[编辑]
堆栈跟踪是:

03/07/11 23:39:44 CEST: Maven Builder: FULL_BUILD   
03/07/11 23:39:44 CEST: [WARN] The POM for com.google.code.gwt-log:gwt-log:jar:3.1.2 is missing, no dependency information available  
03/07/11 23:39:44 CEST: Build errors for fiveorbs; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok (default) on project fiveorbs: Execution default of goal org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok failed: A required class was missing while executing org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok: com/sun/tools/javac/util/Context  
-----------------------------------------------------
realm =    plugin>org.projectlombok:maven-lombok-plugin:0.9.3.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/Daedin/.m2/repository/org/projectlombok/maven-lombok-        plugin/0.9.3.1/maven-lombok-plugin-0.9.3.1.jar
urls[1] = file:/C:/Program%20Files/Java/jdk1.6.0_26/jre/../lib/tools.jar
urls[2] = file:/C:/Users/Daedin/.m2/repository/org/projectlombok/lombok/0.9.3/lombok-0.9.3.jar
urls[3] = file:/C:/Users/Daedin/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

[/Edit]

我的配置如下:

  • Eclipse 3.6 Helios
  • Maven 2.3
  • JDK 1.6
  • Lombok 0.9.3
  • Delombok maven plugin 0.9.3.1

包含 delombok 插件声明的 pom.xml 部分如下:

<plugin>
    <groupId>org.projectlombok</groupId>
    <artifactId>maven-lombok-plugin</artifactId>
    <version>0.9.3.1</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>delombok</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>sun.jdk</groupId>
            <artifactId>tools</artifactId>
            <version>1.6</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
    </dependencies>
</plugin>

如果这个问题看起来微不足道,我很抱歉,但我已经寻找答案几个小时了,而且我开始陷入困境。

预先感谢您提供的任何提示 - 如果我遗漏了任何有用的信息,请告诉我。

I have a maven project in Eclipse that uses lombok/delombok.

When I build, from Eclipse, using a maven script (e.g. mvn clean package), everything works fine.

However, when I run directly from Eclipse (say with a clean/build of my project), I have a classpath issue concerning a class that should be present in the tools.jar from the JDK. I have tried adding the tools.jar directly in my project build path, without any success.

[Edit]
The stack trace is:

03/07/11 23:39:44 CEST: Maven Builder: FULL_BUILD   
03/07/11 23:39:44 CEST: [WARN] The POM for com.google.code.gwt-log:gwt-log:jar:3.1.2 is missing, no dependency information available  
03/07/11 23:39:44 CEST: Build errors for fiveorbs; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok (default) on project fiveorbs: Execution default of goal org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok failed: A required class was missing while executing org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok: com/sun/tools/javac/util/Context  
-----------------------------------------------------
realm =    plugin>org.projectlombok:maven-lombok-plugin:0.9.3.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/Daedin/.m2/repository/org/projectlombok/maven-lombok-        plugin/0.9.3.1/maven-lombok-plugin-0.9.3.1.jar
urls[1] = file:/C:/Program%20Files/Java/jdk1.6.0_26/jre/../lib/tools.jar
urls[2] = file:/C:/Users/Daedin/.m2/repository/org/projectlombok/lombok/0.9.3/lombok-0.9.3.jar
urls[3] = file:/C:/Users/Daedin/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

[/Edit]

My configuration is as follows:

  • Eclipse 3.6 Helios
  • Maven 2.3
  • JDK 1.6
  • Lombok 0.9.3
  • Delombok maven plugin 0.9.3.1

The part of the pom.xml that contains the declaration of the delombok plugin is as follows:

<plugin>
    <groupId>org.projectlombok</groupId>
    <artifactId>maven-lombok-plugin</artifactId>
    <version>0.9.3.1</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>delombok</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>sun.jdk</groupId>
            <artifactId>tools</artifactId>
            <version>1.6</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
    </dependencies>
</plugin>

I apologize if this question seems trivial, but I have been looking for an answer for a couple of hours, and I'm starting to get stuck.

Thanks in advance for any hint you may be able to provide - and please let me know if I have omitted any useful information.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

鹤舞 2024-11-25 10:39:53

您需要确保使用 JDK(而不是 JRE)启动 Eclipse。 的 eclipse.ini 中设置可执行文件的路径

可以肯定的是,在 *x 系统(可能包括 MacOS)上

-vm /path/to/jdk/bin/javaw

:在 Win* 上:(

-vm
C:\path to jdk\bin\javaw.exe

需要位于单独的行上,没有引号 - 请参阅 https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Windows_Example )

到确定Eclipse在哪个JVM下启动,可以使用Help->About、Installation Details、Configuration。然后查找 -vm 行。如果您看到多个 -vm 行,或者 -vm 行指向 JRE 而不是 JDK,请调整 eclipse.ini,然后重新启动 Eclipse 并对项目执行 Maven->Update。

You need to make sure Eclipse is launched using a JDK (not a JRE). To be sure, set the path to the executable in eclipse.ini

on *x systems (probably includind MacOS):

-vm /path/to/jdk/bin/javaw

on Win*:

-vm
C:\path to jdk\bin\javaw.exe

(needs to be on separate lines, no quotes - see https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Windows_Example )

To determine which JVM Eclipse launched under, you can use Help->About, Installation Details, Configuration. Then look for the -vm line. If you see multiple -vm lines, or the -vm line points at a JRE instead of a JDK, adjust eclipse.ini then relaunch Eclipse and do a Maven->Update on the project.

还如梦归 2024-11-25 10:39:53

我认为该问题已在 Lombok 0.10.0 或更高版本中得到解决

I think the problem has been solved in Lombok 0.10.0 or higher

相守太难 2024-11-25 10:39:53

当源使用已安装的 Windows 共享时,在 Linux VM 上进行编译时,我遇到了类似的 delombok 问题。就我而言,问题是通过将存储库移动到 Linux VM 上的另一个位置,然后重新编译来解决的。

I had a similar issue with delombok when compiling on a Linux VM, when the source was using a mounted Windows share. In my case the problem was solved by moving the repository to another location exclusively on the Linux VM, then recompiling.

梦断已成空 2024-11-25 10:39:53

您是否通过执行 lombok.jar 配置了 Eclipse?

Lombok 还需要 javac 1.6 或更高版本

Have you configured your Eclipse by executing lombok.jar?

Also Lombok requires javac 1.6 or higher

狠疯拽 2024-11-25 10:39:53

我昨天下午遇到了这个问题。我正在使用Java 8、Eclipse氧气、maven 3.5.2。

解决方案:
通过从 pom 中删除 Lombok 依赖项并通过单独下载 Lombok jar 将其添加到构建路径中,解决了该问题。

我还编辑了 eclipse.ini 并添加了以下内容:

-javaagent:lombok.jar

我下载了 1.16.18 版本的 Lombok jar。

I had this issue yesterday afternoon. I am using Java 8, Eclipse oxygen, maven 3.5.2.

Solution:
The issue got resolved by removing the Lombok dependency from pom and by adding the Lombok jar in the build path by downloading it separately.

I also edited the eclipse.ini and added the following:

-javaagent:lombok.jar

I downloaded 1.16.18 version of Lombok jar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文