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

Maven-compiler-plugin:3.3: testCompile (default-testCompile) failing on compile Attribute$Error cannot be cast to Attribute$Class

我一直在四处寻找这个问题的解决方案,但我似乎无法找到正确的答案。我相信,我的情况比较特殊,所以问题可能更难解决。
问题的核心是 运行 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 时出现了这个问题。我 运行 遇到了类似的问题,所以我关闭了 b运行ch 并取消了我原来的工作 code/project,现在我似乎无法修复它。

如果您能就此事提供任何帮助,我们将不胜感激。如果可能有帮助,我将 post 我的 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)

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

我尝试了多种解决方案来查找问题的根本原因,发现我的机器编译 类 的时间比平时长,因此我们尝试增加配置中的 maxmem 选项。

我已将我的编译器插件 maxmem 选项从 1024m 更改为 2048m,这解决了问题

对我来说,这个问题是由于我试图在 pom.xml 中使用“默认 maven 配置文件”以及另一个 e2e 测试配置文件引起的。我切换回常规 pom,现在可以使用了。仍然不确定实际原因。