美文网首页
Maven问题-Unable to find main clas

Maven问题-Unable to find main clas

作者: 爱恨_交加 | 来源:发表于2022-02-09 17:47 被阅读0次

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

    1、使用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信息删除后重新执行构建打包,最终打包成功。

    相关文章

      网友评论

          本文标题:Maven问题-Unable to find main clas

          本文链接:https://www.haomeiwen.com/subject/gmzwkrtx.html