使用springboot完成多module项目后通过IDEA工具右边的自带maven编译进行打包的时候,jar包可以正常生成,但是一旦运行jar的时候就会无法启动,具体的原因没有找到,可能是IDEA工具进行多module打包的时候有些加载没有正常加载吧,具体解决的方法如下:
1.我们首先看看jar工具配置
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> <configuration> <mainClass>com.yaya.merchant.MerchantApp</mainClass> </configuration> </plugin> </plugins> </build>
2.这里我们不要选择使用IDEA进行maven打包,进行手动执行maven打包,进入到你自己所在项目最外面层的pom.xml所在目录,通过mvn clean package命令进行打包,打包完成后进入到你想使用的module模块的target目录下,启动jar就可以成功了。具体代码可以参考https://github.com/422518490/orderSystem/blob/alibaba/project/%E4%B8%80%E6%9C%9F/orderSystem/merchant/pom.xml