您的当前位置:首页>全部文章 >"博客"内的文章 >文章详情
springboot+maven搭建多模块依赖项目
发表于:2021-11-16 17:54:42浏览:109次TAG: #springboot #maven #java


springboot+maven搭建多模块依赖项目,本次搭建以搭建队列 配置模块、生产者模块、消费者模块 为例。其中生产者模块、消费者模块依赖配置模块。

① 新建父模块,file -》 New -》Project

0001.jpg

0002.jpg

② 创建对应模块,以配置模块为例:file -》 New -》Mudole

配置模块(config)、生成者模块(product)、消费者模块(consume)

0001.jpg

0003.jpg

③ 父模块pom.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.reer</groupId>
    <artifactId>queue</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>queue</name>
    <description>Demo project for Spring Boot</description>
    <!-- 打包方式配置 子模块配置-->
    <packaging>pom</packaging>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <!-- Spring boot 子模块配置-->
    <modules>
        <module>config</module>
        <module>product</module>
        <module>consume</module>
    </modules>
    <dependencyManagement>
        <dependencies>
            <!-- Spring boot 核心web-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

④ 配置模块被依赖,不可打包成可执行jar包,配置模块pom.xml配置

登录 登录阅读全文