springboot 总模块 搭项目_SpringBoot多模块项目搭建(一)

1. 新建maven项目

1.1 File -> new -> project ->maven

668e583c31350ad19c58c50e0b82933a.png

1.2 设置groupId和artifactId

b277db569357f3e2cadaa1089b9c3220.png

1.3 设置项目名

219234d936218236eabab771b471668f.png

1.4 删除源码目录

2. 新建应用程序入口模块

2.1 右击项目,新建Springboot module

792bec2664b651363d5bdb9a9efd39e6.png

2.2 设置groupId和artifactId

8515c0b448773cdffc66bd3e409b4065.png

2.3 选择需要的依赖(后续引入也行)

建议引入SpringBoot DevTools、Lombok、Spring web

2.4 设置module路径,finish

3. 修改root项目pom.xml

3.1 添加modules,并声明各个module

springboot-base

复制代码

3.2 添加properties,用于配置各种依赖的版本号等其它配置项

1.0-SNAPSHOT

2.2.0.RELEASE

复制代码

3.3 添加dependencyManagement,用于管理各个jar的引入

此时,root项目的pom.xml文件如下

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">

4.0.0

com.jw

springboot-base-root

${springboot-base-version}

springboot-base

1.0-SNAPSHOT

2.2.0.RELEASE

org.springframework.boot

spring-boot-starter-web

${spring.boot.version}

org.springframework.boot

spring-boot-devtools

${spring.boot.version}

runtime

true

org.projectlombok

lombok

${spring.boot.version}

true

org.springframework.boot

spring-boot-starter-test

${spring.boot.version}

test

org.junit.vintage

junit-vintage-engine

复制代码

4. 修改各个子模块的pom.xml

4.1 修改parent为root模块

4.2 修改当前module的version与父模块一致

此时pom.xml文件如下

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.jw

springboot-base-root

${springboot-base-version}

com.jw

springboot-base

${springboot-base-version}

springboot-base

1.8

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-devtools

runtime

true

org.projectlombok

lombok

true

org.springframework.boot

spring-boot-starter-test

test

org.junit.vintage

junit-vintage-engine

org.springframework.boot

spring-boot-maven-plugin

复制代码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值