一、Maven编译报错AssertionError
Maven 编译SpringBoot程序出现错误:2022-09-21 06:38:52 UTC| Exception in thread "main" java.lang.AssertionError
2022-09-21 06:38:11 UTC| Image policy: Always (x.x.x.x/public/maven:3.6-jdk-11-public)2022-09-21 06:38:11 UTC| 3.6-jdk-11-public: Pulling from public/maven2022-09-21 06:38:11 UTC| Digest: sha256:45b427591d6dc1e99c81bf98588d4a145a888cdb5b81ed434c3ba4026f34beaf2022-09-21 06:38:11 UTC| Status: Image is up to date for x.x.x.xx/public/maven:3.6-jdk-11-public2022-09-21 06:38:12 UTC| + mvn -U -B clean deploy2022-09-21 06:38:13 UTC| [INFO] Scanning for projects.....................2022-09-21 06:38:50 UTC| [INFO] Changes detected - recompiling the module!2022-09-21 06:38:50 UTC| [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!2022-09-21 06:38:50 UTC| [INFO] Compiling 50 source files to /workspace/target/classes2022-09-21 06:38:52 UTC| [INFO] ------------------------------------------------------------------------2022-09-21 06:38:52 UTC| [INFO] BUILD FAILURE2022-09-21 06:38:52 UTC| [INFO] ------------------------------------------------------------------------2022-09-21 06:38:52 UTC| [INFO] Total time: 38.637 s2022-09-21 06:38:52 UTC| [INFO] Finished at: 2022-09-21T06:38:52Z2022-09-21 06:38:52 UTC| [INFO] ------------------------------------------------------------------------2022-09-21 06:38:52 UTC| ---------------------------------------------------2022-09-21 06:38:52 UTC| constituent[0]: file:/usr/share/maven/conf/logging/2022-09-21 06:38:52 UTC| constituent[1]: file:/usr/share/maven/lib/cdi-api-1.0.jar2022-09-21 06:38:52 UTC| constituent[2]: file:/usr/share/maven/lib/commons-cli-1.4.jar2022-09-21 06:38:52 UTC| constituent[3]: file:/usr/share/maven/lib/commons-io-2.5.jar2022-09-21 06:38:52 UTC| constituent[4]: file:/usr/share/maven/lib/commons-lang3-3.8.1.jar2022-09-21 06:38:52 UTC| constituent[5]: file:/usr/share/maven/lib/guava-25.1-android.jar2022-09-21 06:38:52 UTC| constituent[6]: file:/usr/share/maven/lib/guice-4.2.1-no_aop.jar2022-09-21 06:38:52 UTC| constituent[7]: file:/usr/share/maven/lib/jansi-1.17.1.jar2022-09-21 06:38:52 UTC| constituent[8]: file:/usr/share/maven/lib/javax.inject-1.jar2022-09-21 06:38:52 UTC| constituent[9]: file:/usr/share/maven/lib/jcl-over-slf4j-1.7.29.jar2022-09-21 06:38:52 UTC| constituent[10]: file:/usr/share/maven/lib/jsoup-1.12.1.jar2022-09-21 06:38:52 UTC| constituent[11]: file:/usr/share/maven/lib/jsr250-api-1.0.jar2022-09-21 06:38:52 UTC| constituent[12]: file:/usr/share/maven/lib/maven-artifact-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[13]: file:/usr/share/maven/lib/maven-builder-support-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[14]: file:/usr/share/maven/lib/maven-compat-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[15]: file:/usr/share/maven/lib/maven-core-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[16]: file:/usr/share/maven/lib/maven-embedder-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[17]: file:/usr/share/maven/lib/maven-model-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[18]: file:/usr/share/maven/lib/maven-model-builder-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[19]: file:/usr/share/maven/lib/maven-plugin-api-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[20]: file:/usr/share/maven/lib/maven-repository-metadata-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[21]: file:/usr/share/maven/lib/maven-resolver-api-1.4.1.jar2022-09-21 06:38:52 UTC| constituent[22]: file:/usr/share/maven/lib/maven-resolver-connector-basic-1.4.1.jar2022-09-21 06:38:52 UTC| constituent[23]: file:/usr/share/maven/lib/maven-resolver-impl-1.4.1.jar2022-09-21 06:38:52 UTC| constituent[24]: file:/usr/share/maven/lib/maven-resolver-provider-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[25]: file:/usr/share/maven/lib/maven-resolver-spi-1.4.1.jar2022-09-21 06:38:52 UTC| constituent[26]: file:/usr/share/maven/lib/maven-resolver-transport-wagon-1.4.1.jar2022-09-21 06:38:52 UTC| constituent[27]: file:/usr/share/maven/lib/maven-resolver-util-1.4.1.jar2022-09-21 06:38:52 UTC| constituent[28]: file:/usr/share/maven/lib/maven-settings-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[29]: file:/usr/share/maven/lib/maven-settings-builder-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[30]: file:/usr/share/maven/lib/maven-shared-utils-3.2.1.jar2022-09-21 06:38:52 UTC| constituent[31]: file:/usr/share/maven/lib/maven-slf4j-provider-3.6.3.jar2022-09-21 06:38:52 UTC| constituent[32]: file:/usr/share/maven/lib/org.eclipse.sisu.inject-0.3.4.jar2022-09-21 06:38:52 UTC| constituent[33]: file:/usr/share/maven/lib/org.eclipse.sisu.plexus-0.3.4.jar2022-09-21 06:38:52 UTC| constituent[34]: file:/usr/share/maven/lib/plexus-cipher-1.7.jar2022-09-21 06:38:52 UTC| constituent[35]: file:/usr/share/maven/lib/plexus-component-annotations-2.1.0.jar2022-09-21 06:38:52 UTC| constituent[36]: file:/usr/share/maven/lib/plexus-interpolation-1.25.jar2022-09-21 06:38:52 UTC| constituent[37]: file:/usr/share/maven/lib/plexus-sec-dispatcher-1.4.jar2022-09-21 06:38:52 UTC| constituent[38]: file:/usr/share/maven/lib/plexus-utils-3.2.1.jar2022-09-21 06:38:52 UTC| constituent[39]: file:/usr/share/maven/lib/slf4j-api-1.7.29.jar2022-09-21 06:38:52 UTC| constituent[40]: file:/usr/share/maven/lib/wagon-file-3.3.4.jar2022-09-21 06:38:52 UTC| constituent[41]: file:/usr/share/maven/lib/wagon-http-3.3.4-shaded.jar2022-09-21 06:38:52 UTC| constituent[42]: file:/usr/share/maven/lib/wagon-provider-api-3.3.4.jar2022-09-21 06:38:52 UTC| ---------------------------------------------------2022-09-21 06:38:52 UTC| Exception in thread "main" java.lang.AssertionError2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:247)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.readSourceFile(JavaCompiler.java:837)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ImplicitCompleter.complete(JavacProcessingEnvironment.java:1530)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.complete(Type.java:1140)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.getTypeArguments(Type.java:1066)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.code.Printer.visitClassType(Printer.java:237)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.code.Printer.visitClassType(Printer.java:52)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:993)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.code.Printer.visit(Printer.java:136)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:199)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:167)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:185)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:167)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.util.JCDiagnostic.getMessage(JCDiagnostic.java:788)2022-09-21 06:38:52 UTC| at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$DiagnosticSourceUnwrapper.getMessage(ClientCodeWrapper.java:799)2022-09-21 06:38:52 UTC| at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:149)2022-09-21 06:38:52 UTC| at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)2022-09-21 06:38:52 UTC| at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)2022-09-21 06:38:52 UTC| at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)2022-09-21 06:38:52 UTC| at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)2022-09-21 06:38:52 UTC| at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)2022-09-21 06:38:52 UTC| at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)2022-09-21 06:38:52 UTC| at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)2022-09-21 06:38:52 UTC| at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)2022-09-21 06:38:52 UTC| at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)2022-09-21 06:38:52 UTC| at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)2022-09-21 06:38:52 UTC| at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)2022-09-21 06:38:52 UTC| at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)2022-09-21 06:38:52 UTC| at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)2022-09-21 06:38:52 UTC| at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)2022-09-21 06:38:52 UTC| at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)2022-09-21 06:38:52 UTC| at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)2022-09-21 06:38:52 UTC| at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)2022-09-21 06:38:52 UTC| at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)2022-09-21 06:38:52 UTC| at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)2022-09-21 06:38:52 UTC| at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)2022-09-21 06:38:52 UTC| at java.base/java.lang.reflect.Method.invoke(Method.java:566)2022-09-21 06:38:52 UTC| at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)2022-09-21 06:38:52 UTC| at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)2022-09-21 06:38:52 UTC| at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)2022-09-21 06:38:52 UTC| at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)2022-09-21 06:38:52 UTC| exit code 1, error 2022-09-21 06:38:52 UTC| WebReportPath is empty, skip web report collect
解决方法1:
上传好第三方jar和jar相关pom文件到私有仓库。参考文档:Maven发布jar到Nexus_summer_west_fish的博客-CSDN博客
解决方法2:
二、spring-boot-maven-plugin未指定版本导致的编译错误
springboot应用在使用maven编译时会报如下错误:
Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M2:repackage (default) on project mis: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M2:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.0.0-M2' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0Caused by: java.lang.UnsupportedClassVersionError: org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
解决方法:添加spring-boot-maven-plugin版本号
org.springframework.boot spring-boot-maven-plugin Greenwich.RELEASE
三、maven编码gbk的不可映射字符
安装系统之后,一般中文系统默认字符集是GBK。我们安装的软件一般都继承使用操作系统的默认字符集。所以当在中文XP或者win7系统开发,在使用maven(mvn compile)编译项目的时候,就会出现“编码 gbk 的不可映射字符”: 这个是由于代码使用的UTF-8,而maven编译的时候使用的GBK的缘故。 可以通过修改项目的pom文件,可以告诉maven这个项目使用UTF-8编码来编译
pom.xml文件中添加下面的配置:
UTF-8
来源地址:https://blog.csdn.net/summer_fish/article/details/127010017