Spring Boot Maven 多模块打包发布

application为启动模块,yml配置文件都在这个模块配置

父模块不要配置<build></build>节点,其他模块也不需要,只在application模块里面配置就好.

打包使用package命令

当整个项目打包成jar时,

该子模块会被打包成jar,此时如果要用代码加载里面的资源文件,不能使用 resource.getFile(),应该使用resource.getInputStream().

 如:

ClassPathResource resource = new ClassPathResource("/static/test.txt"); 
InputStream
in = resource.getInputStream();

若果是不可执行的jar包,不要在pom中定义spring-boot-maven-plugin插件,因为这个SpringBoot插件会在Maven的package后进行二次打包,目的为了生成可执行jar包

原文地址:https://www.cnblogs.com/cearnach/p/9157062.html