首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >maven编译报错:Exception in thread "main" java.lang.AssertionError

maven编译报错:Exception in thread "main" java.lang.AssertionError

作者头像
崔认知
发布2023-06-19 16:49:05
发布2023-06-19 16:49:05
1.8K00
代码可运行
举报
文章被收录于专栏:nobodynobody
运行总次数:0
代码可运行

问题描述


maven编译报错:

代码语言:javascript
代码运行次数:0
运行
复制
constituent[25]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/maven-resolver-connector-basic-1.4.1.jar
constituent[26]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/maven-settings-3.6.3.jar
constituent[27]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/maven-model-3.6.3.jar
constituent[28]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/maven-resolver-api-1.4.1.jar
constituent[29]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/jcl-over-slf4j-1.7.29.jar
constituent[30]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/wagon-http-3.3.4-shaded.jar
constituent[31]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/org.eclipse.sisu.plexus-0.3.4.jar
constituent[32]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/slf4j-api-1.7.29.jar
constituent[33]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/maven-builder-support-3.6.3.jar
constituent[34]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/jsoup-1.12.1.jar
constituent[35]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/wagon-provider-api-3.3.4.jar
constituent[36]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/maven-shared-utils-3.2.1.jar
constituent[37]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/maven-resolver-impl-1.4.1.jar
constituent[38]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/maven-core-3.6.3.jar
constituent[39]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/javax.inject-1.jar
constituent[40]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/commons-lang3-3.8.1.jar
constituent[41]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/guava-25.1-android.jar
constituent[42]: file:/Users/cuirenzhi/opt/apache-maven-3.6.3/lib/jsr250-api-1.0.jar
---------------------------------------------------
Exception in thread "main" java.lang.AssertionError
        at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
        at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
        at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:247)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.readSourceFile(JavaCompiler.java:837)
        at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ImplicitCompleter.complete(JavacProcessingEnvironment.java:1529)
        at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642)
        at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326)
        at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.complete(Type.java:1140)
        at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.getTypeArguments(Type.java:1066)
        at jdk.compiler/com.sun.tools.javac.code.Printer.visitClassType(Printer.java:237)
        at jdk.compiler/com.sun.tools.javac.code.Printer.visitClassType(Printer.java:52)
        at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:993)
        at jdk.compiler/com.sun.tools.javac.code.Printer.visit(Printer.java:136)
        at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:199)
        at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:167)
        at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
        at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)
        at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:185)
        at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:167)
        at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
        at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)
        at jdk.compiler/com.sun.tools.javac.util.JCDiagnostic.getMessage(JCDiagnostic.java:788)
        at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$DiagnosticSourceUnwrapper.getMessage(ClientCodeWrapper.java:799)
        at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:131)
        at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1134)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:187)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

关键地方:

代码语言:javascript
代码运行次数:0
运行
复制
---------------------------------------------------
Exception in thread "main" java.lang.AssertionError
        at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
        at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
        at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:247)

我们发现出错原因很难寻找。

找出出错原因


1、开启debug log模式编译

代码语言:javascript
代码运行次数:0
运行
复制
mvn -X
代码语言:javascript
代码运行次数:0
运行
复制
mvn -e

2、如果还找不到确切原因:

配置插件:

代码语言:javascript
代码运行次数:0
运行
复制
<build>
    <plugins>
        <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
              <forceJavacCompilerUse>true</forceJavacCompilerUse>
              </configuration>
       </plugin>
   </plugins>
</build>

使用javac编译器发现错误原因。

参考:

https://stackoverflow.com/questions/62583298/exception-in-thread-main-java-lang-assertionerror


https://issues.apache.org/jira/browse/MCOMPILER-346

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-06-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 认知科技技术团队 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档