Springboot 多module打包方案示例详解
Springboot 多module打包问题(依赖不存在)解决方案:
参考项目结构如下:

说明: web模块为最终的启动模块,web->service->manager->dao->entity+common
方案1(实际采用):
(1)在最外层父pom:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<!-- 是否过滤资源文件,替换maven属性 - 不过滤,否则过滤xlsx文件导致乱码,XSSFWork读取格式异常 -->
<filtering>false</filtering>
<includes>
<include>**/*</include>
<include>mapper/*.xml</include>
</includes>
</resource>
</resources>
</build>(2)其他子模块POM(非Springboot启动类: common,entity,dao,manager,service):
无需指定<build/>
(3)Springboot启动类子模块POM(web):
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.xxx.MxVehiclePartsApplication(此处替换为相应Springboot启动类)</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>执行mvn package后,可在启动模块(web)target下看到*.jar即为可执行的jar包;

方案2:
(1)在最外层父pom:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.xxx.MxVehiclePartsApplication(此处替换为相应Springboot启动类)</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<!-- 是否过滤资源文件,替换maven属性 - 不过滤,否则过滤xlsx文件导致乱码,XSSFWork读取格式异常 -->
<filtering>false</filtering>
<includes>
<include>**/*</include>
<include>mapper/*.xml</include>
</includes>
</resource>
</resources>
</build>
(2)其他子模块POM(非Springboot启动类: common,entity,dao,manager,service):
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>(3)Springboot启动类子模块POM(web):
无需指定<build/>
到此这篇关于Springboot 多module打包方案的文章就介绍到这了,更多相关Springboot module打包内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
SpringBoot + MQTT实现取货就走的智能售货柜系统完整流程
本文介绍了一种智能售货柜的工作原理和实现流程,该系统通过多传感器数据融合、实时视频流处理和异步处理,提供无感购物体验,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧2026-03-03
Lombok @Slf4j log对象没有info等方法不可用问题及解决
本文主要介绍了如何解决Spring Boot项目中的日志依赖冲突问题,以及如何使用Lombok和SLF4J进行日志记录,Lombok通过生成Logger对象简化了日志记录,而SLF4J提供了一个统一的日志接口,允许开发者在运行时选择不同的日志实现2024-12-12


最新评论