笔记——Spring-Boot-Maven(多模块项目)

前置条件:
        工具:IntelliJ IDEA 2021.1
        Maven版本:apache-maven-3.6.0
        JDK版本:1.8

一、创建聚合父工程

1.选择New--Project

 2.选中Maven。--Next。

 3.键入项目名、项目路径、GroupId、ArtifactId。--Finist.

 4.创建完成之后,删掉src文件;只保留pom.xml文件。初始目录结构如下

 5.在pom.xml文件中声明父工程及包含的子模块。

<project xmlns="http://maven.apache.org/POM/4.0.0"
         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">
    <!-- 基本信息 -->
    <description>springboot学习笔记</description>
    <modelVersion>4.0.0</modelVersion>
    <name>spring-boot-learns</name>
    <!--
         packing默认是jar类型
         pom 夫类型都为pom类型,它生成的构建只是它本身,没有任何代码需要测试或编译,也没有任何资源需要处理
         jar 内部调用或做服务使用
         war 需要部署的项目
         -->
    <packaging>pom</packaging>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <!-- 作为这个聚合项目的父工程 -->
    <groupId>spring.boot.learns</groupId>
    <artifactId>SpringBootLearns</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- 继承说明、继承spring-boot提供的父工程 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.12</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <!-- 模块说明、声明多个子模块-->
    <modules>
        <module>learn-basics</module>
    </modules>

</project>

二、创建子模块(module)

1.对着父工程右键 - New - Module

2. 键入module名、路径

3.选择spring boot版本,勾选Web——Spring Web。--finist.

 4.创建完成,查看完整目录结构。

 

 5.修改子模块的pom.xml文件。

    <parent>
        <groupId>spring.boot.learns</groupId>
        <artifactId>SpringBootLearns</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <name>learn-basics</name>
    <description>spring-boot基础</description>

    <groupId>learn.basics</groupId>
    <artifactId>LearnBasics</artifactId>
    <version>0.0.1-SNAPSHOT</version>

 基本也就这样了......

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值