草庐IT

Maven常见的编译报错

summer_west_fish 2023-04-25 原文

一、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/maven
2022-09-21 06:38:11 UTC| Digest: sha256:45b427591d6dc1e99c81bf98588d4a145a888cdb5b81ed434c3ba4026f34beaf
2022-09-21 06:38:11 UTC| Status: Image is up to date for x.x.x.xx/public/maven:3.6-jdk-11-public
2022-09-21 06:38:12 UTC| + mvn -U -B clean deploy
2022-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/classes
2022-09-21 06:38:52 UTC| [INFO] ------------------------------------------------------------------------
2022-09-21 06:38:52 UTC| [INFO] BUILD FAILURE
2022-09-21 06:38:52 UTC| [INFO] ------------------------------------------------------------------------
2022-09-21 06:38:52 UTC| [INFO] Total time:  38.637 s
2022-09-21 06:38:52 UTC| [INFO] Finished at: 2022-09-21T06:38:52Z
2022-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.jar
2022-09-21 06:38:52 UTC| constituent[2]: file:/usr/share/maven/lib/commons-cli-1.4.jar
2022-09-21 06:38:52 UTC| constituent[3]: file:/usr/share/maven/lib/commons-io-2.5.jar
2022-09-21 06:38:52 UTC| constituent[4]: file:/usr/share/maven/lib/commons-lang3-3.8.1.jar
2022-09-21 06:38:52 UTC| constituent[5]: file:/usr/share/maven/lib/guava-25.1-android.jar
2022-09-21 06:38:52 UTC| constituent[6]: file:/usr/share/maven/lib/guice-4.2.1-no_aop.jar
2022-09-21 06:38:52 UTC| constituent[7]: file:/usr/share/maven/lib/jansi-1.17.1.jar
2022-09-21 06:38:52 UTC| constituent[8]: file:/usr/share/maven/lib/javax.inject-1.jar
2022-09-21 06:38:52 UTC| constituent[9]: file:/usr/share/maven/lib/jcl-over-slf4j-1.7.29.jar
2022-09-21 06:38:52 UTC| constituent[10]: file:/usr/share/maven/lib/jsoup-1.12.1.jar
2022-09-21 06:38:52 UTC| constituent[11]: file:/usr/share/maven/lib/jsr250-api-1.0.jar
2022-09-21 06:38:52 UTC| constituent[12]: file:/usr/share/maven/lib/maven-artifact-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[13]: file:/usr/share/maven/lib/maven-builder-support-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[14]: file:/usr/share/maven/lib/maven-compat-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[15]: file:/usr/share/maven/lib/maven-core-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[16]: file:/usr/share/maven/lib/maven-embedder-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[17]: file:/usr/share/maven/lib/maven-model-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[18]: file:/usr/share/maven/lib/maven-model-builder-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[19]: file:/usr/share/maven/lib/maven-plugin-api-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[20]: file:/usr/share/maven/lib/maven-repository-metadata-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[21]: file:/usr/share/maven/lib/maven-resolver-api-1.4.1.jar
2022-09-21 06:38:52 UTC| constituent[22]: file:/usr/share/maven/lib/maven-resolver-connector-basic-1.4.1.jar
2022-09-21 06:38:52 UTC| constituent[23]: file:/usr/share/maven/lib/maven-resolver-impl-1.4.1.jar
2022-09-21 06:38:52 UTC| constituent[24]: file:/usr/share/maven/lib/maven-resolver-provider-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[25]: file:/usr/share/maven/lib/maven-resolver-spi-1.4.1.jar
2022-09-21 06:38:52 UTC| constituent[26]: file:/usr/share/maven/lib/maven-resolver-transport-wagon-1.4.1.jar
2022-09-21 06:38:52 UTC| constituent[27]: file:/usr/share/maven/lib/maven-resolver-util-1.4.1.jar
2022-09-21 06:38:52 UTC| constituent[28]: file:/usr/share/maven/lib/maven-settings-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[29]: file:/usr/share/maven/lib/maven-settings-builder-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[30]: file:/usr/share/maven/lib/maven-shared-utils-3.2.1.jar
2022-09-21 06:38:52 UTC| constituent[31]: file:/usr/share/maven/lib/maven-slf4j-provider-3.6.3.jar
2022-09-21 06:38:52 UTC| constituent[32]: file:/usr/share/maven/lib/org.eclipse.sisu.inject-0.3.4.jar
2022-09-21 06:38:52 UTC| constituent[33]: file:/usr/share/maven/lib/org.eclipse.sisu.plexus-0.3.4.jar
2022-09-21 06:38:52 UTC| constituent[34]: file:/usr/share/maven/lib/plexus-cipher-1.7.jar
2022-09-21 06:38:52 UTC| constituent[35]: file:/usr/share/maven/lib/plexus-component-annotations-2.1.0.jar
2022-09-21 06:38:52 UTC| constituent[36]: file:/usr/share/maven/lib/plexus-interpolation-1.25.jar
2022-09-21 06:38:52 UTC| constituent[37]: file:/usr/share/maven/lib/plexus-sec-dispatcher-1.4.jar
2022-09-21 06:38:52 UTC| constituent[38]: file:/usr/share/maven/lib/plexus-utils-3.2.1.jar
2022-09-21 06:38:52 UTC| constituent[39]: file:/usr/share/maven/lib/slf4j-api-1.7.29.jar
2022-09-21 06:38:52 UTC| constituent[40]: file:/usr/share/maven/lib/wagon-file-3.3.4.jar
2022-09-21 06:38:52 UTC| constituent[41]: file:/usr/share/maven/lib/wagon-http-3.3.4-shaded.jar
2022-09-21 06:38:52 UTC| constituent[42]: file:/usr/share/maven/lib/wagon-provider-api-3.3.4.jar
2022-09-21 06:38:52 UTC| ---------------------------------------------------
2022-09-21 06:38:52 UTC| Exception in thread "main" java.lang.AssertionError
2022-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.0
Caused 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版本号

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
				<version>Greenwich.RELEASE</version>
            </plugin>
        </plugins>

    </build>

三、maven编码gbk的不可映射字符

 安装系统之后,一般中文系统默认字符集是GBK。我们安装的软件一般都继承使用操作系统的默认字符集。所以当在中文XP或者win7系统开发,在使用maven(mvn compile)编译项目的时候,就会出现“编码 gbk 的不可映射字符”: 这个是由于代码使用的UTF-8,而maven编译的时候使用的GBK的缘故。 可以通过修改项目的pom文件,可以告诉maven这个项目使用UTF-8编码来编译

pom.xml文件中添加下面的配置:

<properties>
	 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

有关Maven常见的编译报错的更多相关文章

  1. ruby - Sinatra set cache_control to static files in public folder编译错误 - 2

    我不知道为什么,但是当我设置这个设置时它无法编译设置:static_cache_control,[:public,:max_age=>300]这是我得到的syntaxerror,unexpectedtASSOC,expecting']'(SyntaxError)set:static_cache_control,[:public,:max_age=>300]^我只想将“过期”header设置为css、javaascript和图像文件。谢谢。 最佳答案 我猜您使用的是Ruby1.8.7。Sinatra文档中显示的语法似乎是在Ruby1.

  2. 深度学习部署:Windows安装pycocotools报错解决方法 - 2

    深度学习部署:Windows安装pycocotools报错解决方法1.pycocotools库的简介2.pycocotools安装的坑3.解决办法更多Ai资讯:公主号AiCharm本系列是作者在跑一些深度学习实例时,遇到的各种各样的问题及解决办法,希望能够帮助到大家。ERROR:Commanderroredoutwithexitstatus1:'D:\Anaconda3\python.exe'-u-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-instal

  3. git使用常见问题(提交代码,合并冲突) - 2

    文章目录git常用命令(简介,详细参数往下看)Git提交代码步骤gitpullgitstatusgitaddgitcommitgitpushgit代码冲突合并问题方法一:放弃本地代码方法二:合并代码常用命令以及详细参数gitadd将文件添加到仓库:gitdiff比较文件异同gitlog查看历史记录gitreset代码回滚版本库相关操作远程仓库相关操作分支相关操作创建分支查看分支:gitbranch合并分支:gitmerge删除分支:gitbranch-ddev查看分支合并图:gitlog–graph–pretty=oneline–abbrev-commit撤消某次提交git用户名密码相关配置g

  4. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  5. ruby - 将对象设置为 nil 是否很常见? - 2

    我正在构建一个应用程序,想知道是否将未使用的对象设置为nil是生产级编码中的常见做法。我知道这只是垃圾收集器的提示,并不总是处理对象。 最佳答案 根据这个thread如果您使用完一个成员对象,将其设置为nil将引发被引用对象被垃圾回收。如果它是局部变量,方法exit将做同样的事情。也就是说,如果您要求将成员显式设置为nil,我会质疑您的设计。 关于ruby-将对象设置为nil是否很常见?,我们在StackOverflow上找到一个类似的问题: https://

  6. ruby - 变量赋值后的 if 语句 - 有多常见? - 2

    我最近与一位同事讨论了以下Ruby语法:value=ifa==0"foo"elsifa>42"bar"else"fizz"end我个人并没有看到太多这种逻辑,但我的同事指出,这实际上是一种相当普遍的Rubyism。我试着用谷歌搜索这个主题,但没有找到任何文章、页面或SO问题来讨论它,这让我相信这可能是一种非常实际的技术。然而,另一位同事发现语法令人困惑,而是将上面的逻辑写成这样:ifa==0value="foo"elsifa>42value="bar"elsevalue="fizz"end缺点是value=的重复声明和隐式elsenil的丢失,如果我们想使用它的话。这也感觉它与Ruby

  7. .net - 是否有 Ruby .NET 编译器? - 2

    是否有适用于Ruby语言的.NETFramework编译器?我听说过DLR(动态语言运行时),这是否将使Ruby能够用于.NET开发? 最佳答案 IronRuby是Microsoft支持的项目,建立在动态语言运行时之上。 关于.net-是否有Ruby.NET编译器?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/199638/

  8. python - 使用 Python、Ruby 和 Perl 重新编译 MacPort 版本的 MacVim - 2

    关闭。这个问题是off-topic.它目前不接受答案。想改进这个问题吗?Updatethequestion所以它是on-topic用于堆栈溢出。关闭10年前。ImprovethisquestionLinux专家正在转向Mac(10.8)。因为我懒...我使用MacPorts安装MacVim。它似乎安装没有错误。我只需要mvim中的python、ruby和perl支持。$/opt/local/bin/mvim--version|egrep'patches|python|ruby|perl'Includedpatches:1-244,246-646+multi_lang-mzscheme+

  9. ruby - 为什么 `middleman serve` 有效,但是 `middleman build` 编译这个 Sass 失败? - 2

    当我刚刚运行middleman时服务,all.css编译得很好,只包含对+box-shadow(none)的调用:/*line1,/home/yang/asdf/source/stylesheets/content.css.sass*/div{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}但是当我构建网站时,我得到了这个Sass/Compass错误:$middlemanbuildSlim::EmbeddedEngineisdeprecated,itiscalledSlim::EmbeddedinSlim2.0

  10. 常见网络安全产品汇总(私信发送思维导图) - 2

    安全产品安全网关类防火墙Firewall防火墙防火墙主要用于边界安全防护的权限控制和安全域的划分。防火墙•信息安全的防护系统,依照特定的规则,允许或是限制传输的数据通过。防火墙是一个由软件和硬件设备组合而成,在内外网之间、专网与公网之间的界面上构成的保护屏障。下一代防火墙•下一代防火墙,NextGenerationFirewall,简称NGFirewall,是一款可以全面应对应用层威胁的高性能防火墙,提供网络层应用层一体化安全防护。生产厂家•联想网御、CheckPoint、深信服、网康、天融信、华为、H3C等防火墙部署部署于内、外网编辑额,用于权限访问控制和安全域划分。UTM统一威胁管理(Un

随机推荐