在运行pom.xml时获取org.testng的pOM:testng:jar:5.14.3无效且java.lang.NoClassDefFoundError

问题描述 投票:0回答:1

在运行pom.xml时获取java.lang.NoClassDefFoundError,我已经更新了maven依赖项中的maven surefire插件以及更新的maven版本,但仍然收到错误,

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building eGem 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.testng:testng:jar:5.14.3 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.testng:testng:jar:5.14.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.testng:testng:jar:5.14.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.beust:jcommander:jar:1.66 is missing, no dependency information available
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ eGem ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 13 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ eGem ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ eGem ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 12 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ eGem ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ eGem ---
[WARNING] Error injecting: org.apache.maven.plugin.surefire.SurefirePlugin
java.lang.NoClassDefFoundError: org/apache/maven/surefire/util/NestedCheckedException
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
java maven
1个回答
0
投票

尝试添加配置部分并查看它是否有效,或者在调试模式下运行maven以进行进一步调试。

<project>
      [...]
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.21.0</version>
            <configuration>
              <useSystemClassLoader>false</useSystemClassLoader>
            </configuration>
          </plugin>
        </plugins>
      </build>
      [...]
    </project>

调试类路径问题以下是一些尝试的一般提示:

  • 使用--debug(或等效地,-X)运行Maven以获得更详细的输出检查forkCount。如果forkCount = 0(或forkMode = never,不推荐使用的版本),则不可能使用系统类加载器或普通的旧Java类路径;我们必须使用一个孤立的类加载器。
  • 如果您使用的是默认值,请使用SystemClassLoader = true和useManifestOnlyJar = false。在这种情况下,请查看生成的仅清单Surefire引导程序JAR。打开它(它只是一个拉链)并阅读它的清单。
  • 使用-Dmaven.surefire.debug运行Maven,并使用调试器附加到正在运行的进程。
© www.soinside.com 2019 - 2024. All rights reserved.