SpringBoot多模块打包异常解决办法:Unable to find main class

您所在的位置:网站首页 maven多module打包 SpringBoot多模块打包异常解决办法:Unable to find main class

SpringBoot多模块打包异常解决办法:Unable to find main class

#SpringBoot多模块打包异常解决办法:Unable to find main class| 来源: 网络整理| 查看: 265

困扰了两天的一个问题: 自己写了一个SpringCloud项目,下面有很多模块,有的是公共依赖、有的是一个SpringBoot启动项目。打成jar包的时候总是不成功,报以下异常:。 Execution default of goal org.springframew ork.boot:spring-boot-maven-plugin:2.0.8.RELEASE:repackage failed: Unable to find main class

首先先来看下我的pom文件: 复制代码

这是我的父级Pom文件,在里面依赖了打包插件: ${project.artifactId} org.springframework.boot spring-boot-maven-plugin 复制代码

原因就是多模块的项目不能把打包插件放到父级Pom中,只需在你子模块的SpringBoot独立运行的项目模块中依赖即可,如果是公共依赖的子模块(比如我项目中的core模块是一个公共依赖)也不需要依赖这个打包插件。 最后打包成功后的依赖图如下:

父级Pom去掉打包插件依赖。

子模块SpringBoot服务模块添加打包插件依赖:



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3