先创建一个"父项目"mall,再在这个父项目中创建多个子项目
修改pom文件
最终mall的pom文件如下
4.0.0 org.springframework.boot spring-boot-starter-parent 2.5.4 com.taobao mall 0.0.1-SNAPSHOT mall Demo project for Spring Boot pom
在父项目的pom文件中,编写子项目的存在
pom mall-stock
子项目pom文件修改后
4.0.0 com.taobao mall 0.0.1-SNAPSHOT com.taobao mall-stock 0.0.1-SNAPSHOT mall-stock Demo project for Spring Boot org.springframework.boot spring-boot-starter
父子相认完成
这样当前子项目就可以读取父项目中的pom文件信息了
这样做可以统一所有子项目的版本,在更新版本时,只需要修改父项目中定义的版本号即可
父项目的pom文件添加如下内容
2.2.2 org.mybatis.spring.boot mybatis-spring-boot-starter ${mybatis.version}
子项目中如果需要mybatis的依赖只需要添加如下内容即可,无需再指定版本号
org.mybatis.spring.boot mybatis-spring-boot-starter
父项目完整pom文件如下
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.5.9
com.taobao
mall
0.0.1-SNAPSHOT
mall
Demo project for Spring Boot
pom
mall-stock
1.8
2020.0.3
2.2.2.RELEASE
2.5.4
2.3.0.RELEASE
1.0.10.RELEASE
2.2.0
3.4.1
1.4.0
8.0.26
1.18.20
2.0.9
2.3.10
5.5.2
1.2.45
1.1.20
0.9.0
1.4.2
org.projectlombok
lombok
io.seata
seata-all
${seata-server.version}
org.projectlombok
lombok
${lombok.version}
mysql
mysql-connector-java
${mysql.version}
runtime
com.alibaba
druid
${druid.version}
org.mybatis.spring.boot
mybatis-spring-boot-starter
${mybatis-spring-boot.version}
com.baomidou
mybatis-plus-boot-starter
${mybaits-plus.version}
com.baomidou
mybatis-plus-generator
${mybaits-plus.version}
com.github.pagehelper
pagehelper-spring-boot-starter
${pagehelper-spring-boot.version}
org.springframework.boot
spring-boot-starter
${spring-boot.version}
org.springframework.boot
spring-boot-starter-web
${spring-boot.version}
org.springframework.boot
spring-boot-starter-freemarker
${spring-boot.version}
org.springframework.boot
spring-boot-starter-validation
${spring-boot.version}
org.springframework.boot
spring-boot-starter-security
${spring-boot.version}
org.springframework.boot
spring-boot-starter-oauth2-client
${spring-boot.version}
org.springframework.boot
spring-boot-configuration-processor
${spring-boot-configuration-processor.version}
org.springframework.security
spring-security-jwt
${spring-security-jwt.version}
com.github.xiaoymin
knife4j-spring-boot-starter
${knife4j-spring-boot.version}
org.springframework.boot
spring-boot-starter-data-redis
${spring-boot.version}
org.springframework.boot
spring-boot-starter-data-mongodb
${spring-boot.version}
org.springframework.boot
spring-boot-starter-data-elasticsearch
${spring-boot.version}
org.springframework.boot
spring-boot-starter-amqp
${spring-boot.version}
org.springframework.boot
spring-boot-starter-actuator
${spring-boot.version}
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
com.alibaba.cloud
spring-cloud-alibaba-dependencies
${spring-cloud-alibaba.version}
pom
import
com.alibaba
fastjson
${fastjson.version}
io.jsonwebtoken
jjwt
${jjwt.version}
org.springframework.boot
spring-boot-starter-test
${spring-boot.version}
test
org.springframework.amqp
spring-rabbit-test
${spring-rabbit-test.version}
test
org.springframework.security
spring-security-test
${spring-security-test.version}
test
io.seata
seata-spring-boot-starter
${seata-server.version}
父子相认
mall-commons
子项目pom文件最终如下
4.0.0 com.taobao/groupId> mall 0.0.1-SNAPSHOT com.taobao mall-commons 0.0.1-SNAPSHOT mall-commons Demo project for Spring Boot com.github.xiaoymin knife4j-spring-boot-starter org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-json org.springframework.boot spring-boot-starter-tomcat
当前模块只是编写通用类和代码