Maven问题-Unable to find main class

简介: Maven问题-Unable to find main class

问题

同一问题的原因可能存在多种,这里的方式仅供参考

描述:使用jenkins打包基于springboot的多web模块项目时出现Unable to find main class

15:05:33 [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.3.RELEASE:repackage (default) on project plat-cabinet: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.3.RELEASE:repackage failed: Unable to find main class -> [Help 1]
15:05:33 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.3.RELEASE:repackage (default) on project plat-cabinet: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.3.RELEASE:repackage failed: Unable to find main class
15:05:33     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
15:05:33     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
15:05:33     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
15:05:33     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
15:05:33     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
15:05:33     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
15:05:33     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
15:05:33     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
15:05:33     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
15:05:33     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
15:05:33     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
15:05:33     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
15:05:33     at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
15:05:33     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
15:05:33     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
15:05:33     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
15:05:33     at java.lang.reflect.Method.invoke (Method.java:498)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
15:05:33 Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.3.RELEASE:repackage failed: Unable to find main class
15:05:33     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
15:05:33     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
15:05:33     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
15:05:33     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
15:05:33     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
15:05:33     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
15:05:33     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
15:05:33     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
15:05:33     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
15:05:33     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
15:05:33     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
15:05:33     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
15:05:33     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
15:05:33     at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
15:05:33     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
15:05:33     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
15:05:33     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
15:05:33     at java.lang.reflect.Method.invoke (Method.java:498)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
15:05:33 Caused by: java.lang.IllegalStateException: Unable to find main class
15:05:33     at org.springframework.boot.loader.tools.Repackager.buildManifest (Repackager.java:354)
15:05:33     at org.springframework.boot.loader.tools.Repackager.repackage (Repackager.java:273)
15:05:33     at org.springframework.boot.loader.tools.Repackager.repackage (Repackager.java:258)
15:05:33     at org.springframework.boot.loader.tools.Repackager.repackage (Repackager.java:190)
15:05:33     at org.springframework.boot.maven.RepackageMojo.repackage (RepackageMojo.java:212)
15:05:33     at org.springframework.boot.maven.RepackageMojo.execute (RepackageMojo.java:199)
15:05:33     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
15:05:33     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
15:05:33     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
15:05:33     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
15:05:33     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
15:05:33     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
15:05:33     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
15:05:33     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
15:05:33     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
15:05:33     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
15:05:33     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
15:05:33     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
15:05:33     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
15:05:33     at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
15:05:33     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
15:05:33     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
15:05:33     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
15:05:33     at java.lang.reflect.Method.invoke (Method.java:498)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
15:05:33     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

解决方式

在项目的根目录下直接使用maven命令执行构建打包(开发环境和测试环境),发现有这个差异:

[WARNING] The POM for xxx.xxx.xxx:arcface:jar:1.0.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

开发环境一直以来都打包正常,对比发现没有如上信息,抱着试一试的心态,在测试环境的仓库中把对应的jar信息删除后重新执行构建打包,最终打包成功。

相关文章
|
缓存 Java Maven
IDEA配置maven和踩坑记录(Unable to import maven project)
IDEA配置maven和踩坑记录(Unable to import maven project)
1042 0
|
6月前
|
Java Maven 开发工具
maven导入项目出现Unable to import maven project: See logs for details
maven导入项目出现Unable to import maven project: See logs for details
56 0
maven导入项目出现Unable to import maven project: See logs for details
|
3月前
|
Java Maven Spring
Maven重打包问题之maven-shade-plugin插件对于重复的class文件会如何处理
Maven重打包问题之maven-shade-plugin插件对于重复的class文件会如何处理
|
3月前
|
Java Maven
IDEA 报 Unable to import maven project: See logs for details
IDEA 报 Unable to import maven project: See logs for details
48 0
|
4月前
|
IDE Java Maven
Unable to import Maven project,Maven依赖全爆红的问题解决
Unable to import Maven project,Maven依赖全爆红的问题解决
|
Java Maven
idea中maven打包工具类 repackage failed: Unable to find main class
idea中maven打包工具类 repackage failed: Unable to find main class
334 1
|
算法 IDE Java
springBoot导入本地jar并且要求通过maven打包到项目的jar中|Unable to open nested jar file 'BOOT-INF/lib/xxxxxx.jar'
springBoot导入本地jar并且要求通过maven打包到项目的jar中|Unable to open nested jar file 'BOOT-INF/lib/xxxxxx.jar'
|
Java Maven
解决 idea中 Unable to reload Maven project
解决 idea中 Unable to reload Maven project
469 0
|
Java Maven
maven项目右键new没有java class
maven项目右键new没有java class
maven项目右键new没有java class
|
缓存 Java Maven
你该如何解决 idea中 Unable to reload Maven project 以及 maven安装配置(内附代码/有安装包)
你该如何解决 idea中 Unable to reload Maven project 以及 maven安装配置(内附代码/有安装包)
840 0
你该如何解决 idea中 Unable to reload Maven project 以及 maven安装配置(内附代码/有安装包)