gpt4 book ai didi

java - Maven-compiler-plugin:3.3: testCompile (default-testCompile) 编译失败 Attribute$Error 无法转换为 Attribute$Class

转载 作者:行者123 更新时间:2023-11-30 11:00:19 31 4
gpt4 key购买 nike

我一直在四处寻找这个问题的解决方案,但我似乎无法找到正确的答案。我相信,我的情况比较特殊,所以这个问题可能更难解决。
问题的核心是我在运行 mvn test 命令时收到的错误消息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:testCompile (default-testCompile) on project DriveServiceFitnesse: Fatal error compiling: java.lang.ClassCastException: com.sun.tools.javac.code.Attribute$Error cannot be cast to com.sun.tools.javac.code.Attribute$Class -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

但是 mvn compile 并没有通过错误。但是由于我需要 mvn test 来生成测试源,所以我的测试实际上并没有起作用。我知道这是因为,当我运行我的测试时,我得到了这个错误:

    Error:java: java.lang.ClassCastException: 
com.sun.tools.javac.code.Attribute$Error cannot be cast to
com.sun.tools.javac.code.Attribute$Class

用于编译和运行的项目没有问题。当我尝试将我的项目从 Maven 转换为 Gradle 时出现了这个问题。我遇到了类似的问题,所以我关闭了分支并取消了我原来的工作代码/项目,现在我似乎无法修复它。

如能提供有关此事的任何帮助,我们将不胜感激。如果可能有帮助,我会发布我的 pom.xml 文件。

*编辑:根据我在堆栈跟踪消息中粘贴的建议,我得到:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:testCompile (default-testCompile) on project DriveServiceFitnesse: Fatal error compiling: java.lang.ClassCastException: com.sun.tools.javac.code.Attribute$Error cannot be cast to com.sun.tools.javac.code.Attribute$Class -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:testCompile (default-testCompile) on project DriveServiceFitnesse: Fatal error compiling
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:836)
at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:153)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)

最佳答案

修正了这个错误。是我的疏忽。问题是出于某种原因,我使用“项目结构”(在 intellij 中)导入的本地 jar 不知何故过期了,即库仍然在列表中,但没有被正确地拉入项目。我删除了引用并重新导入,一切似乎都正常了……唉。

关于java - Maven-compiler-plugin:3.3: testCompile (default-testCompile) 编译失败 Attribute$Error 无法转换为 Attribute$Class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31571054/

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