参考博客:多模块项目父子pom设置
要求:多Module之间的依赖关系首先我们在IDEA中创建一个spring boot工程作为父项目。
注意:配置pom文件,双击打开pom.xml之后将packaging更改为pom
删除src目录
创建Maven项目 注意:选择父模块,选择后会在父模块中的modules标签中加入子模块的说明:
说明:
- 创建好后在,在父模块的pom.xml中modules下加入刚才创建的子模块。
注意:
- 在子模块的pom.xml文件,将其中parent更改为对应父模块的信息。
和第二步一样,创建Maven项目:
和第二步一样,创建Maven项目:
这一步最好在IDEA中创建一个spring boot工程作为web模块
注意:在每一个子Module中都要通过parent标签引入它所依赖的上一级Module。
parent的pom.xml父pom是为了抽取统一的配置信息和依赖版本控制,方便子pom直接引用,简化子pom的配置。
4.0.0
com.hc
crowdfunding-parent
0.0.1-SNAPSHOT
../crowdfunding-common
crowdfunding-parent
众筹项目
pom
1.8
UTF-8
UTF-8
2.2.6.RELEASE
org.projectlombok
lombok
true
junit
junit
4.12
org.springframework.boot
spring-boot-starter-test
org.junit.vintage
junit-vintage-engine
commons-codec
commons-codec
1.13
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-devtools
runtime
true
org.springframework.boot
spring-boot-starter-logging
com.alibaba
druid-spring-boot-starter
1.1.22
org.springframework.boot
spring-boot-starter-jdbc
com.fasterxml.jackson.core
jackson-core
2.10.1
com.fasterxml.jackson.core
jackson-databind
2.10.1
com.fasterxml.jackson.core
jackson-annotations
2.10.1
mysql
mysql-connector-java
runtime
com.alibaba
druid
1.1.21
com.baomidou
mybatis-plus-boot-starter
3.3.0
com.baomidou
mybatis-plus
3.3.0
com.baomidou
mybatis-plus-core
3.3.0
com.baomidou
mybatis-plus-extension
3.3.0
com.baomidou
mybatis-plus-annotation
3.3.0
org.mybatis
mybatis-typehandlers-jsr310
1.0.2
org.springframework.boot
spring-boot-configuration-processor
true
org.springframework.boot
spring-boot-dependencies
${spring-boot.version}
pom
import
org.apache.maven.plugins
maven-compiler-plugin
1.8
1.8
UTF-8
org.springframework.boot
spring-boot-maven-plugin
2.2.6.RELEASE
common的pom.xml
4.0.0
com.hc
crowdfunding-parent
0.0.1-SNAPSHOT
com.hc
crowdfunding-common
0.0.1-SNAPSHOT
../crowdfunding-manager
../crowdfunding-portal
crowdfunding-common
http://www.example.com
pom
UTF-8
1.8
1.8
.....
manager的pom.xml
4.0.0
com.hc
crowdfunding-common
0.0.1-SNAPSHOT
com.hc
crowdfunding-manager
0.0.1-SNAPSHOT
crowdfunding-manager
http://www.example.com
jar
UTF-8
1.8
1.8
com.hc
crowdfunding-common
0.0.1-SNAPSHOT
....
portal的pom.xml
4.0.0
com.hc
crowdfunding-common
0.0.1-SNAPSHOT
com.hc
crowdfunding-portal
0.0.1-SNAPSHOT
crowdfunding-portal
http://www.example.com
jar
UTF-8
1.8
1.8
com.hc
crowdfunding-common
0.0.1-SNAPSHOT
....
web的pom.xml
4.0.0
com.hc
crowdfunding-manager
0.0.1-SNAPSHOT
com.hc
crowdfunding-web
1.0-SNAPSHOT
war
crowdfunding-web Maven Webapp
http://www.example.com
UTF-8
1.8
1.8
com.hc
crowdfunding-manager
0.0.1-SNAPSHOT
com.hc
crowdfunding-portal
0.0.1-SNAPSHOT
......
第六步:在web Module中添加配置文件和启动类,并进行测试