gpt4 book ai didi

java - 使用 maven/eclipse 的 AspectJ 编译为 org/aspectj/bridge/IMessageHolder 抛出 NoClassDefFoundError

转载 作者:行者123 更新时间:2023-11-30 11:07:55 36 4
gpt4 key购买 nike

我最近在我的 Windows 7 机器上从 eclipse Juno 升级到 Luna,我的 aspectj 编译出现问题。我收到此错误:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile (default) on project RSADirectoryUtilities: Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile failed: A required class was missing while executing org.codehaus.mojo:aspectj-maven-plugin:1.7:compile: org/aspectj/bridge/IMessageHolder
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:aspectj-maven-plugin:1.7
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/DJC/.m2/repository/org/codehaus/mojo/aspectj-maven-plugin/1.7/aspectj-maven-plugin-1.7.jar
[ERROR] urls[1] = file:/C:/Users/DJC/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.10/plexus-utils-3.0.10.jar
[ERROR] urls[2] = file:/C:/Users/DJC/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[3] = file:/C:/Users/DJC/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
[ERROR] urls[4] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
[ERROR] urls[5] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
[ERROR] urls[6] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[ERROR] urls[7] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-site-renderer/1.1.2/doxia-site-renderer-1.1.2.jar
[ERROR] urls[8] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-core/1.1.2/doxia-core-1.1.2.jar
[ERROR] urls[9] = file:/C:/Users/DJC/.m2/repository/xerces/xercesImpl/2.8.1/xercesImpl-2.8.1.jar
[ERROR] urls[10] = file:/C:/Users/DJC/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
[ERROR] urls[11] = file:/C:/Users/DJC/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar
[ERROR] urls[12] = file:/C:/Users/DJC/.m2/repository/commons-codec/commons-codec/1.2/commons-codec-1.2.jar
[ERROR] urls[13] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-decoration-model/1.1.2/doxia-decoration-model-1.1.2.jar
[ERROR] urls[14] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-module-xhtml/1.1.2/doxia-module-xhtml-1.1.2.jar
[ERROR] urls[15] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-module-fml/1.1.2/doxia-module-fml-1.1.2.jar
[ERROR] urls[16] = file:/C:/Users/DJC/.m2/repository/org/codehaus/plexus/plexus-i18n/1.0-beta-7/plexus-i18n-1.0-beta-7.jar
[ERROR] urls[17] = file:/C:/Users/DJC/.m2/repository/org/codehaus/plexus/plexus-velocity/1.1.7/plexus-velocity-1.1.7.jar
[ERROR] urls[18] = file:/C:/Users/DJC/.m2/repository/org/apache/velocity/velocity/1.5/velocity-1.5.jar
[ERROR] urls[19] = file:/C:/Users/DJC/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar
[ERROR] urls[20] = file:/C:/Users/DJC/.m2/repository/commons-collections/commons-collections/3.2/commons-collections-3.2.jar
[ERROR] urls[21] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/reporting/maven-reporting-impl/2.1/maven-reporting-impl-2.1.jar
[ERROR] urls[22] = file:/C:/Users/DJC/.m2/repository/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0.jar
[ERROR] urls[23] = file:/C:/Users/DJC/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar
[ERROR] urls[24] = file:/C:/Users/DJC/.m2/repository/commons-digester/commons-digester/1.6/commons-digester-1.6.jar
[ERROR] urls[25] = file:/C:/Users/DJC/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar
[ERROR] urls[26] = file:/C:/Users/DJC/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[ERROR] urls[27] = file:/C:/Users/DJC/.m2/repository/org/aspectj/aspectjtools/1.8.2/aspectjtools-1.8.2.jar
[ERROR] urls[28] = file:/C:/Program%20Files/Java/jdk1.8.0_31/jre/../lib/tools.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.aspectj.bridge.IMessageHolder

我的 pom 看起来像这样:

 <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version>
</dependency>

.....

    <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<!-- use this goal to weave all your main classes -->
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<complianceLevel>1.8</complianceLevel>
<target>1.8</target>
<source>1.6</source>
<verbose>true</verbose>
</configuration>
</plugin>

一些有趣的事情需要注意。当我在 eclipse 之外(在 linux 机器上)运行 mvn package 时,这很好用。我有 2 个同事,他们都能够在 eclipse 中进行 maven 打包(他们最近也都升级了)。唯一的区别是他们通过了 Juno 的升级路径,而我只是做了一个全新的“安装”并指出了 Luna 和我的工作区(它升级了)。我一个接一个地检查插件,试图找出他们的安装与我的安装之间的区别,但这并没有解决这个问题。我的想法用完了。

solution对我来说似乎已经过时并且不起作用。

运行 mvn dependency:tree yields

[INFO] Building xxxDirectoryUtilities 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) @ xxxDirectoryUtilities ---
[INFO] xxxDirectoryUtilities:jar:0.0.1-SNAPSHOT
[INFO] +- junit:junit:jar:4.4:test
[INFO] +- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] +- org.springframework:spring-context:jar:2.5.6:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.springframework:spring-core:jar:2.5.6:compile
[INFO] +- org.springframework:spring-tx:jar:2.5.6:compile
[INFO] +- org.springframework:spring-beans:jar:2.5.6:compile
[INFO] +- org.springframework.ldap:spring-ldap-core:jar:1.3.0.RELEASE:compile
[INFO] | \- commons-lang:commons-lang:jar:2.1:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.7.3:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.7.3:compile
[INFO] +- xxxLoggingUtilities:jar:0.0.1-SNAPSHOT:compile
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] +- xxxCryptographyUtils:jar:0.0.1-SNAPSHOT:compile
[INFO] | \- org.jasypt:jasypt-spring2:jar:1.9.1:compile
[INFO] | \- org.jasypt:jasypt:jar:1.9.1:compile
[INFO] \- xxx:UnifiedSpringResourceFiles:jar:0.0.1-SNAPSHOT:compile
[INFO] \- org.springframework:spring:jar:2.5.6:compile

最佳答案

您的 Maven 配置有一些潜在的问题:

  • 您使用 AspectJ Maven 插件 1.7,它使用编译器版本 1.8.2。
  • 但是您依赖于 AspectJ Runtime 1.7.3。 (顺便说一句,1.7.4 是最新的 1.7.x AspectJ 版本。)
  • 您的字节码目标版本是 1.8,但 AspectJ Runtime 1.7.x 不支持 Java 8。

我通常做的是:

  • 确保编译器和运行时版本同步。我什至覆盖了 AspectJ Maven 插件中的 AspectJ 工具版本,只是为了 100% 确定我有最新的编译器修复。
  • 通常我也使用相同的源、目标和合规级别版本。不痛。

您可以根据需要调整此示例:

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.source-target.version>1.7</java.source-target.version>
<aspectj.version>1.8.5</aspectj.version>
<main-class>de.scrum_master.galileo.OpenbookCleaner</main-class>
</properties>

<!-- (...) -->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${java.source-target.version}</source>
<target>${java.source-target.version}</target>
<!-- IMPORTANT -->
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<!--<showWeaveInfo>true</showWeaveInfo>-->
<source>${java.source-target.version}</source>
<target>${java.source-target.version}</target>
<Xlint>ignore</Xlint>
<complianceLevel>${java.source-target.version}</complianceLevel>
<encoding>${project.build.sourceEncoding}</encoding>
<!--<verbose>true</verbose>-->
<!--<warn>constructorName,packageDefaultMethod,deprecation,maskedCatchBlocks,unusedLocals,unusedArguments,unusedImport</warn>-->
</configuration>
<executions>
<execution>
<!-- IMPORTANT -->
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>

<!-- (...) -->

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
<scope>runtime</scope>
</dependency>

<!-- (...) -->

看看是否有帮助。

关于java - 使用 maven/eclipse 的 AspectJ 编译为 org/aspectj/bridge/IMessageHolder 抛出 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28697565/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com