使用idea+maven给springboot多模块结构打jar包

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33243189/article/details/89352057

     首先介绍项目结构,父工程:hfmp,子模块:affairs(springboot)、information(springboot)、model(java工程)、common(java工程),依赖关系:affairs依赖model和comm;information依赖model和common。如图

hfmp父工程的pom.xml(只摘取部分关键代码),注意不需要<build>maven插件:

affairs模块的pom.xml(information区别<artifactId>information</artifactId><name>information</name>):

model模块的pom.xml(common的区别<artifactId>common</artifactId>):

使用idea >> maven projects >> hfmp >> lifecycle ,先clean然后package。在项目的目录下~\hfmp\xxx\target生成xxx-1.0-SNAPSHOT.jar,直接运行"java -jar xxx-1.0-SNAPSHOT.jar"。(~\hfmp\affairs\target和~\hfmp\information\target 目录下)

注意:在linux环境下(通过xshell连接)运行"java -jar xxx-1.0-SNAPSHOT.jar",项目成功运行后关闭窗口或者ctrl+z,会直接关闭掉项目,所以需要通过nohup和&命令配合:"nohup java -jar xxx-1.0-SNAPSHOT.jar &",在目录下会生成nohup.out日志文件查看:"tail -f nohup.out"就可以查看项目日志了。nohup Command &:不挂断后台运行(防止关闭窗口和ctrl+z停止命令)

猜你喜欢

转载自blog.csdn.net/qq_33243189/article/details/89352057