springBoot父子工程

springBoot父子工程

创建工程

在工程创建时 可以使用idea将父工程设置为maven pom 江表示这个是一个父工程

父工程pom文件配置

配置springboot起步依赖

父工程需要继承springboot的起步依赖,以供子工程来继承

<!--父工程 pom.xml-->
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <!--	springBoot的起步依赖-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.3.3</version>
    </parent>

    <!--	设置父工程的包 此处父工程一定要设置成pom-->
    <packaging>pom</packaging>
    <!--    父工程id-->
    <groupId>com.springboot</groupId>
    <artifactId>springboot</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <!--	父工程关联子模块-->
    <modules>
        <module>springboot-text</module>
    </modules>
</project>
<!--子工程pom.xml-->
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <!--    子项继承父项-->
    <parent>
        <groupId>com.springboot</groupId>
        <artifactId>springboot</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <!--	子项的id-->
    <artifactId>springboot-text</artifactId>

    <!--    设置子模块的包 用于打包 一定奥设置成jar-->
    <packaging>jar</packaging>
</project>

上次更新 2025/3/25 20:24:25