在本系列第一篇文章,我们讲解了如何在 IDEA 中搭建第一个 SpringBoot 项目:【SpringBoot】一、创建第一个SpringBoot项目,本篇文章,我们讲解如何在 IDEA 中搭建 SpringBoot 的父子 Module 工程项目

1、Module 工程项目 简介

多模块项目,适用于一些比较大的项目,通过合理的模块拆分,实现代码的复用,便于维护和管理。尤其是一些开源框架,也是采用多模块的方式,提供插件集成,用户可以根据需要配置指定的模块。

2、创建一个 SpringBoot 项目

就是创建一个普通的 SpringBoot 项目,项目名称为 springboot

创建项目过程参考我的博客:【SpringBoot】一、创建第一个SpringBoot项目
我们勾选 Spring Web 这一个依赖
创建完后的项目 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
org.springframework.boot
spring-boot-starter-parent
2.3.3.RELEASE
com.zyxx
springboot
0.0.1-SNAPSHOT
springboot
Demo project for Spring Boot
1.8
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
org.junit.vintage
junit-vintage-engine
org.springframework.boot
spring-boot-maven-plugin
/project>
?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.3.3.RELEASE
com.zyxx
admin
0.0.1-SNAPSHOT
admin
Demo project for Spring Boot
1.8
org.springframework.boot
spring-boot-starter
org.projectlombok
lombok
true
org.springframework.boot
spring-boot-starter-test
test
org.junit.vintage
junit-vintage-engine
/exclusions>
br />
br />
plugin>
org.springframework.boot
spring-boot-maven-plugin
/artifactId>
br />
改变后:
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.zyxx
admin
0.0.1-SNAPSHOT
jar
com.zyxx
springboot
0.0.1-SNAPSHOT
admin
Demo project for Spring Boot
org.projectlombok
lombok
true
改变了 packaging 方式为 jar
改变了 parent 的指向为 springboot
去掉了多余的依赖和配置信息
4、修改主项目 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.zyxx
springboot
0.0.1-SNAPSHOT
pom
org.springframework.boot
spring-boot-starter-parent
2.3.3.RELEASE
admin
springboot
Demo project for Spring Boot
1.8
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
org.junit.vintage
junit-vintage-engine
org.springframework.boot
spring-boot-maven-plugin
改变了 packaging 方式为 pom
modules,注册了模块工程 admin
此时,我们已经完成了父子 module 工程项目的搭建,按照此方法,可以搭建更多的子工程
如您在阅读中发现不足,欢迎留言!!!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/134098.html