Spring Boot多模块项目打包
例如父项目 build_test 下面有三个子模块,一个是common模块 一个是a模块,一个b模块;其中common是公共模块,a和b都依赖于公共模块common,我现在想把a和b模块打包成jar包。
创建项目
创建父工程
创建3个子模块,分别是common和a和b模块
鼠标右击红框位置
选New 再选Module,鼠标左键点一下,
同理创建出后面两个模块,最后删除父工程的src目录
项目创建成功
添加项目依赖
build_test 父工程的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hongchun</groupId>
<artifactId>build_test</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>common</module>
<module>a</module>
<module>b</module>
</modules>
<dependencyManagement>
<dependencies>
<!-- SpringBoot的依赖配置-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.3.12.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--mybatisPlus依赖-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3</version>
</dependency