分销网站建设,深圳市地图,东莞市网络seo推广服务机构,用html5制作个人网站第1步#xff1a;新建一个SpringBoot 项目 作为 父工程 [Ref] 新建一个SpringBoot项目
删除无用的 .mvn 目录、 src 目录、 mvnw 及 mvnw.cmd 文件#xff0c;最终只留 .gitignore 和 pom.xml
第2步#xff1a;创建 子maven模块 第3步#xff1a;整理 父 pom 文件
① …第1步新建一个SpringBoot 项目 作为 父工程 [Ref] 新建一个SpringBoot项目
删除无用的 .mvn 目录、 src 目录、 mvnw 及 mvnw.cmd 文件最终只留 .gitignore 和 pom.xml
第2步创建 子maven模块 第3步整理 父 pom 文件
① 删除 dependencies 标签及其中的 spring-boot-starter 和 spring-boot-starter-test 依赖因为 Spring Boot 提供的父工程已包含并且父 pom 原则上都是通过 dependencyManagement 标签管理依赖包。 ② 删除 build 标签及其中的所有内容spring-boot-maven-plugin 插件作用是打一个可运行的包多模块项目仅仅需要在 入口类所在的模块 添加打包插件这里父模块不需要打包运行。而且该插件已被包含在 Spring Boot 提供的父工程中这里删掉即可。 ③ 最后整理父 pom 文件中的其余内容按其代表含义归类整理结果如下
?xml version1.0 encodingUTF-8?
project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd!-- 基本信息 --modelVersion4.0.0/modelVersionpackagingpom/packagingnameParentSpringBoot/namedescriptionParentSpringBoot/description!-- 项目说明这里作为聚合工程的父工程 --groupIdcom.example/groupIdartifactIdParentSpringBoot/artifactIdversion0.0.1-SNAPSHOT/version!-- 继承说明这里继承Spring Boot提供的父工程 --parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.2.1/versionrelativePath/ !-- lookup parent from repository --/parent!-- 模块说明这里声明多个子模块 --modulesmodulemodule1/module/modules!-- 属性说明 --propertiesjava.version17/java.version/properties
/project第4步添加入口类
选择某个module添加入口类
dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency
/dependenciesimport org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplication
public class DemoApplication {public static void main(String[] args) {SpringApplication.run(DemoApplication.class, args);}
}第5步配置模块间的依赖关系 propertiesjava.version17/java.versionmodule1.version0.0.1-SNAPSHOT/module1.version
/propertiesdependencyManagementdependenciesdependencygroupIdcom.example/groupIdartifactIdmodule1/artifactIdversion${module1.version}/version/dependency/dependencies
/dependencyManagement第6步启动SonApplication 参考
IDEA 中搭建 Spring Boot Maven 多模块项目