1. 新建maven项目
1.1 File -> new -> project ->maven
1.2 设置groupId和artifactId
1.3 设置项目名
1.4 删除源码目录
2. 新建应用程序入口模块
2.1 右击项目,新建Springboot module
2.2 设置groupId和artifactId
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
复制代码