搭建聚合工程案例2

配置工程
(1)对主项目pom.xml文件添加配置;
(2)对子模块基础模块、权限模块、系统模块的pom.xml文件添加配置;
(3)对应用模块pom.xml文件添加配置;
第一步、配置主项目的pom.xml文件

  <!--  设定主项目为SpringBoot项目 -->
<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
    </parent>

<!--  项目基本信息配置 -->
    <name>通用后台管理系统</name>
    <description>快速搭建开发平台</description>

<!--  项目编码及JDK版本配置 -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <!-- 指定maven编译的jdk版本,如果不指定,maven3默认用jdk 1.5 maven2默认用jdk1.3 -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <!--  把源代码中的文件,打包到相应位置。这里指定以@包含的变量指定的文件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <delimiters>
                        <delimiter>@</delimiter>
                    </delimiters>
                    <useDefaultDelimiters>false</useDefaultDelimiters>
                </configuration>
            </plugin>
        </plugins>
        <!--  指定需要打包的文件和过滤的文件目录。这里指定将mapper的xml打包;指定web目录不过滤;指定项目资源目录过滤; -->
        <resources>
            <resource>
                <directory>src/main/webapp</directory>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>

    <!--  指定项目当前的application文件-->
    <profiles>
        <profile>
            <id>local</id>
            <properties>
                <spring.active>local</spring.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>dev</id>
            <properties>
                <spring.active>dev</spring.active>
            </properties>
        </profile>
    </profiles>

第二步、配置基础模块的pom.xml文件

<properties>
       <kaptcha.version>2.3.2</kaptcha.version>
        <oshi.version>3.9.1</oshi.version>
        <mysql.version>8.0.19</mysql.version>
        <fastjson.version>1.2.62</fastjson.version>
        <hutool.version>5.2.4</hutool.version>
        <common-lang3.version>3.9</common-lang3.version>
        <commons-collections4.version>4.4</commons-collections4.version>
        <commons-codec.version>1.4</commons-codec.version>
        <commons-email.version>1.5</commons-email.version>
        <guava.version>28.2-jre</guava.version>
        <redis-client.version>3.2.0</redis-client.version>
        <lombok.version>1.18.12</lombok.version>
        <mybatis-plus.version>3.3.0</mybatis-plus.version>
        <druid.version>1.1.21</druid.version>
        <beetl.version>3.0.20.RELEASE</beetl.version>
        <pinyin4j.version>2.5.1</pinyin4j.version>
        <logback.version>1.2.3</logback.version>
        <jjwt.version>0.9.1</jjwt.version>
    </properties>

    <!--所有项目依赖-->
    <dependencies>
        <!--验证码-->
        <dependency>
            <groupId>com.github.penggle</groupId>
            <artifactId>kaptcha</artifactId>
            <version>${kaptcha.version}</version>
        </dependency>
        <!-- 获取系统信息 -->
        <dependency>
            <groupId>com.github.oshi</groupId>
            <artifactId>oshi-core</artifactId>
            <version>${oshi.version}</version>
        </dependency>
        <!--spring boot依赖-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <!--数据库驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>
        <!-- JSON 处理工具 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>
        <!--工具类-->
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-core</artifactId>
            <version>${hutool.version}</version>
        </dependency>
        <!-- 日常工具 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${common-lang3.version}</version>
        </dependency>
        <!-- 数据结构工具 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>${commons-collections4.version}</version>
        </dependency>
        <!-- 编解码工具 -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>${commons-codec.version}</version>
        </dependency>
        <!-- 电子邮件工具 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-email</artifactId>
            <version>${commons-email.version}</version>
        </dependency>
        <!-- guava工具 -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <!-- 引入 redis 的依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>${redis-client.version}</version>
        </dependency>
        <!--自动代码注入和日志-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>
        <!-- 引入MybatisPlus的依赖-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>${mybatis-plus.version}</version>
        </dependency>
        <!-- 引入连接池Druid的依赖-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <!--beetl模板引擎-->
        <dependency>
            <groupId>com.ibeetl</groupId>
            <artifactId>beetl</artifactId>
            <version>${beetl.version}</version>
        </dependency>
        <!-- 中文拼音转换-->
        <dependency>
            <groupId>com.belerweb</groupId>
            <artifactId>pinyin4j</artifactId>
            <version>${pinyin4j.version}</version>
        </dependency>
        <!-- 日志组件-->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback.version}</version>
        </dependency>
        <!--jwt token认证-->
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>${jjwt.version}</version>
        </dependency>

    </dependencies>

<!-- 指定模块打包名称 -->
    <build>
        <finalName>${project.artifactId}</finalName>
    </build>

第三步、配置权限模块的pom.xml文件:

<dependencies>
        <!-- 项目公共基础包 -->
        <dependency>
            <groupId>com.1daoyun</groupId>
            <artifactId>common-platform-base</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
    </build>

第四步、配置系统模块的pom.xml文件

<dependencies>
        <!-- 项目公共基础包 -->
        <dependency>
            <groupId>com.1daoyun</groupId>
            <artifactId>common-platform-base</artifactId>
            <version>1.0.0</version>
        </dependency>

        <!-- 项目权限管理包 -->
        <dependency>
            <groupId>com.1daoyun</groupId>
            <artifactId>common-platform-auth</artifactId>
            <version>1.0.0</version>
        </dependency>

    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
    </build>

第五步、配置应用模块的pom.xml文件:

<dependencies>
<!-- 项目系统管理包 -->
        <dependency>
            <groupId>com.1daoyun</groupId>
            <artifactId>common-platform-sys</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <fork>true</fork><!-- 如果没有该项配置,devtools不会起作用,即应用不会restart -->
                </configuration>
            </plugin>
        </plugins>
    </build>

建立模块项目包
(1)为支撑模块中的基础模块建立项目包;
(2)为支撑模块中的权限模块建立项目包;
(3)为支撑模块中的系统模块建立项目包;
(4)为应用模块建立项目包;
第一步、创建基础模块项目包com.common.platform.base;
第二步、创建权限模块项目包com.common.platform.auth;
第三步、创建系统模块项目包com.common.platform.sys;
第四步、创建应用模块项目包com.common.platform;
注意,应用模块为整个项目的入口,包名必须为主包名。
最终目录结构如下:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值