栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

springboot项目进行 mvn install 时报错 repackage failed: Unable to find main class 处理记录

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springboot项目进行 mvn install 时报错 repackage failed: Unable to find main class 处理记录

异常描述:springboot项目进行 mvn install时 报错如下

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.7.RELEASE:repackage (repackage) on project match-service: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.7.RELEASE:repackage failed: Unable to find main class

排查报错原因:
在各模块的pom.xml中均引入了maven 打包插件

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

在插件运行时
需要指定或者继承了spring-boot-starter-parent并且配置需属性,然后插件会自动寻找签名是public static void main(String[] args)的方法… ,
mainClass和statrt-class即程序的入口,即使用了@SpringBootApplication注解且有main方法的启动类,
我这里的原因是,由于没有添加启动类。所以执行mvn install时会报上述异常

解决办法:
添加启动类或者注释掉没有启动类的模块pom中的上述依赖。

附加知识点:
下配置mainClass,指定程序入口。


    org.springframework.boot
    spring-boot-maven-plugin
    1.5.3.RELEASE
    
        com.xx.webapps.api.main.WebappsApiBidMain
    
    
        
            
                repackage
            
        
    

Spring Boot Maven Plugin提供了几个目标(goal),我们在标签里配置的repackage对应spring-boot:repackage这个目标。

如果你的pom继承自spring-boot-starter-parent(注意此前提),也可以直接在配置(其实这里的start-class直接对应清单文件里的Start-Class):


    com.xx.webapps.api.main.WebappsApiBidMain

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/749305.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号