Windows环境Maven编译打包报错,Mac打包正常

#头条创作挑战赛# #maven#

Windows Maven报错(Mac打包正常):

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project xx-common-base: Compilation failure

Maven打包错误堆栈信息:

mvn clean package -X

-nowarn -target 1.8 -source 1.8 -encoding UTF-8 -bootclasspath C:Program FilesJavajdk1.8.0_251jre/lib/rt.jar:C:Program FilesJavajdk1.8.0_251jre/lib/jce.jar

[DEBUG] incrementalBuildHelper#beforeRebuildExecution

[INFO] Compiling 29 source files to D:xxxxxx-commonsxxx-common-base	argetclasses

致命错误: 在类路径或引导类路径中找不到程序包 java.lang

[DEBUG] incrementalBuildHelper#afterRebuildExecution

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR :

[INFO] -------------------------------------------------------------

[ERROR] An unknown compilation problem occurred

[INFO] 1 error

[INFO] ------------------------------------------------------------ -

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 2.275 s

[INFO] Finished at: 2023-04-04T11:41:21+08:00

[INFO] Final Memory: 16M/185M

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project xxx-common-base: Compilation failure

[ERROR] An unknown compilation problem occurred

[ERROR] -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project xxx-common-base: Compilation failure

An unknown compilation problem occurred

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)

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:863)

at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)

at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

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)

at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure

An unknown compilation problem occurred

at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1220)

at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:187)

at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)

... 21 more

[ERROR]

[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/MojoFailureException

Process finished with exit code 1

问题排查:

问题关键提示信息: 报java.lang包没找到,怀疑跟环境变量或Windows jdk路径有关

1.排查java环境变量=> 正常

2.怀疑跟Windows jdk路径相关 => 根因

问题原因

Windows环境Maven compiler插件路径问题


问题fix方案:

如下所示的配置很特殊:Windows 下使用分号(;)分隔,Linux/Mac 下使用冒号(:)分隔

修改后重新Maven打包正常,问题修复



org.apache.maven.plugins

maven-compiler-plugin

${maven.compiler.version}



${java.version}

${java.version}

UTF-8





srcmainwebappWEB-INFlib



${java.home}/lib/rt.jar:${java.home}/lib/jce.jar






我是架构师kimze,喜欢我的文章欢迎关注我,

我会坚持分享干货: 互联网微服务架构、云原生架构、行业动态、经典案例、技术趋势,

有问题欢迎关注私信或评论区回复交流

点赞、收藏、转发、评论 对我是一种支持,感谢!

展开阅读全文

页面更新:2024-04-24

标签:流点   冒号   干货   分号   堆栈   挑战赛   路径   架构   环境变量   错误   环境

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top