• 父子工程搭建


    1. 构建父工程

    父工程的职责是对依赖包的版本进行管理,创建父工程分两步,第一创建父工程,第二在pom.xml编辑依赖管理。

    进入新建模块界面,选择Spring Initializr,填写模块的信息:

    创建成功,删除多余文件:

    2、依赖管理定义

    父工程中没有代码,不用去依赖其它的包,它的作用是限定其它子工程依赖包的版本号,即在dependencyManagement中去编辑即可。

    1)确定父工程为一个pom工程,在pom.xml中添加如下内容:

    <packaging>pompackaging>
    
    • 1

    2)编辑依赖的包的版本号、打包插件等。

    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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0modelVersion>
        <groupId>com.xuechenggroupId>
        <artifactId>xuecheng-plus-parentartifactId>
        <version>0.0.1-SNAPSHOTversion>
        <name>xuecheng-plus-parentname>
        <description>xuecheng-plus-parentdescription>
        <packaging>pompackaging>
    
        <properties>
            <java.version>1.8java.version>
            <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
            <spring-boot.version>2.3.7.RELEASEspring-boot.version>
            <spring-cloud.version>Hoxton.SR9spring-cloud.version>
            <org.mapstruct.version>1.3.1.Finalorg.mapstruct.version>
            <spring-cloud-alibaba.version>2.2.6.RELEASEspring-cloud-alibaba.version>
            <org.projectlombok.version>1.18.8org.projectlombok.version>
            <javax.servlet-api.version>4.0.1javax.servlet-api.version>
            <fastjson.version>1.2.83fastjson.version>
            <druid-spring-boot-starter.version>1.2.8druid-spring-boot-starter.version>
            <mysql-connector-java.version>8.0.30mysql-connector-java.version>
            <mybatis-plus-boot-starter.version>3.4.1mybatis-plus-boot-starter.version>
            <commons-lang.version>2.6commons-lang.version>
            <minio.version>8.4.3minio.version>
            <xxl-job-core.version>2.3.1xxl-job-core.version>
            <swagger-annotations.version>1.5.20swagger-annotations.version>
            <commons-lang3.version>3.10commons-lang3.version>
            <okhttp.version>4.8.1okhttp.version>
            <swagger-spring-boot-starter.version>1.9.0.RELEASEswagger-spring-boot-starter.version>
            <elasticsearch.version>7.12.1elasticsearch.version>
        properties>
    
    
        <dependencyManagement>
            <dependencies>
    
                <dependency>
                    <groupId>org.springframework.cloudgroupId>
                    <artifactId>spring-cloud-dependenciesartifactId>
                    <version>${spring-cloud.version}version>
                    <type>pomtype>
                    <scope>importscope>
                dependency>
                <dependency>
                    <groupId>org.springframework.bootgroupId>
                    <artifactId>spring-boot-dependenciesartifactId>
                    <version>${spring-boot.version}version>
                    <type>pomtype>
                    <scope>importscope>
                dependency>
                <dependency>
                    <groupId>com.alibaba.cloudgroupId>
                    <artifactId>spring-cloud-alibaba-dependenciesartifactId>
                    <version>${spring-cloud-alibaba.version}version>
                    <type>pomtype>
                    <scope>importscope>
                dependency>
                
                <dependency>
                    <groupId>org.projectlombokgroupId>
                    <artifactId>lombokartifactId>
                    <version>${org.projectlombok.version}version>
                dependency>
                
                <dependency>
                    <groupId>org.mapstructgroupId>
                    <artifactId>mapstruct-jdk8artifactId>
                    <version>${org.mapstruct.version}version>
                dependency>
                <dependency>
                    <groupId>org.mapstructgroupId>
                    <artifactId>mapstruct-processorartifactId>
                    <version>${org.mapstruct.version}version>
                dependency>
                <dependency>
                    <groupId>io.swaggergroupId>
                    <artifactId>swagger-annotationsartifactId>
                    <version>${swagger-annotations.version}version>
                dependency>
                
                <dependency>
                    <groupId>javax.servletgroupId>
                    <artifactId>javax.servlet-apiartifactId>
                    <version>${javax.servlet-api.version}version>
                    <scope>providedscope>
                dependency>
                
                <dependency>
                    <groupId>com.alibabagroupId>
                    <artifactId>fastjsonartifactId>
                    <version>${fastjson.version}version>
                dependency>
                
                <dependency>
                    <groupId>com.alibabagroupId>
                    <artifactId>druid-spring-boot-starterartifactId>
                    <version>${druid-spring-boot-starter.version}version>
                dependency>
    
                
                <dependency>
                    <groupId>mysqlgroupId>
                    <artifactId>mysql-connector-javaartifactId>
                    <version>${mysql-connector-java.version}version>
                dependency>
                
                <dependency>
                    <groupId>com.baomidougroupId>
                    <artifactId>mybatis-plus-boot-starterartifactId>
                    <version>${mybatis-plus-boot-starter.version}version>
                dependency>
    
                
                <dependency>
                    <groupId>com.baomidougroupId>
                    <artifactId>mybatis-plus-generatorartifactId>
                    <version>${mybatis-plus-boot-starter.version}version>
                dependency>
    
                
                <dependency>
                    <groupId>commons-langgroupId>
                    <artifactId>commons-langartifactId>
                    <version>${commons-lang.version}version>
                dependency>
                
                <dependency>
                    <groupId>io.miniogroupId>
                    <artifactId>minioartifactId>
                    <version>${minio.version}version>
                dependency>
                
                <dependency>
                    <groupId>com.google.guavagroupId>
                    <artifactId>guavaartifactId>
                    <version>25.0-jreversion>
                dependency>
                
                <dependency>
                    <groupId>com.xuxueligroupId>
                    <artifactId>xxl-job-coreartifactId>
                    <version>${xxl-job-core.version}version>
                dependency>
                
                <dependency>
                    <groupId>org.springframework.bootgroupId>
                    <artifactId>spring-boot-starter-testartifactId>
                    <version>${spring-boot.version}version>
                    <scope>testscope>
                    <exclusions>
                        <exclusion>
                            <groupId>org.junit.vintagegroupId>
                            <artifactId>junit-vintage-engineartifactId>
                        exclusion>
                    exclusions>
                dependency>
                <dependency>
                    <groupId>com.squareup.okhttp3groupId>
                    <artifactId>okhttpartifactId>
                    <version>${okhttp.version}version>
                dependency>
                <dependency>
                    <groupId>org.apache.commonsgroupId>
                    <artifactId>commons-lang3artifactId>
                    <version>${commons-lang3.version}version>
                dependency>
                <dependency>
                    <groupId>com.spring4allgroupId>
                    <artifactId>swagger-spring-boot-starterartifactId>
                    <version>${swagger-spring-boot-starter.version}version>
                dependency>
                <dependency>
                    <groupId>org.elasticsearch.clientgroupId>
                    <artifactId>elasticsearch-rest-high-level-clientartifactId>
                    <version>${elasticsearch.version}version>
                dependency>
    
                <dependency>
                    <groupId>org.elasticsearchgroupId>
                    <artifactId>elasticsearchartifactId>
                    <version>${elasticsearch.version}version>
                dependency>
            dependencies>
    
        dependencyManagement>
    
        <build>
            <finalName>${project.name}finalName>
            
            <resources>
                <resource>
                    <directory>src/main/resourcesdirectory>
                    <filtering>truefiltering>
                    <includes>
                        <include>**/*include>
                    includes>
                resource>
                <resource>
                    <directory>src/main/javadirectory>
                    <includes>
                        <include>**/*.xmlinclude>
                    includes>
                resource>
            resources>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.pluginsgroupId>
                    <artifactId>maven-compiler-pluginartifactId>
                    <version>3.8.1version>
                    <configuration>
                        
                        <source>1.8source>
                        
                        <target>1.8target>
                        
                        <annotationProcessorPaths>
                            <path>
                                <groupId>org.projectlombokgroupId>
                                <artifactId>lombokartifactId>
                                <version>${org.projectlombok.version}version>
                            path>
                        annotationProcessorPaths>
                    configuration>
                plugin>
    
                
                <plugin>
                    <groupId>org.apache.maven.pluginsgroupId>
                    <artifactId>maven-resources-pluginartifactId>
                    <version>3.3.0version>
                    <configuration>
                        <encoding>utf-8encoding>
                        
                        <useDefaultDelimiters>trueuseDefaultDelimiters>
                    configuration>
                plugin>
            plugins>
        build>
    project>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243

    2. 构建子工程

    1、首先在项目根目录创建内容管理模块的父工程xuecheng-plus-content:

    创建完成,只保留pom.xml文件,删除多余的文件。

    内容管理父工程的主要职责是聚合内容管理接口和内容管理接口实现两个工程,它的父工程是xuecheng-plus-parent。

    
    <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.0modelVersion>
        <parent>
            <artifactId>xuecheng-plus-parentartifactId>
            <groupId>com.xuechenggroupId>
            <version>0.0.1-SNAPSHOTversion>
            <relativePath>../xuecheng-plus-parentrelativePath>
        parent>
        <artifactId>xuecheng-plus-contentartifactId>
        <name>xuecheng-plus-contentname>
        <description>xuecheng-plus-contentdescription>
        <packaging>pompackaging>
    
      <modules>
        <module>xuecheng-plus-content-apimodule>
        <module>xuecheng-plus-content-modelmodule>
        <module>xuecheng-plus-content-servicemodule>
       modules>
    project>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    2、在其下创建model数据模型工程。

    创建完成,只保留包和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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0modelVersion>
        <parent>
            <artifactId>xuecheng-plus-contentartifactId>
            <groupId>com.xuechenggroupId>
            <version>0.0.1-SNAPSHOTversion>
        parent>
        <artifactId>xuecheng-plus-content-modelartifactId>
        <dependencies>
                    <dependency>
                <groupId>com.xuechenggroupId>
                <artifactId>xuecheng-plus-baseartifactId>
                <version>0.0.1-SNAPSHOTversion>
            dependency>
        dependencies>
    project>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    3、在其下创建service接口实现工程。

    创建完成,只保留包和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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0modelVersion>
        <parent>
            <artifactId>xuecheng-plus-contentartifactId>
            <groupId>com.xuechenggroupId>
            <version>0.0.1-SNAPSHOTversion>
        parent>
        <artifactId>xuecheng-plus-content-serviceartifactId>
            <dependencies>
            <dependency>
                <groupId>com.xuechenggroupId>
                <artifactId>xuecheng-plus-content-modelartifactId>
                <version>0.0.1-SNAPSHOTversion>
            dependency>
         dependencies>
    project>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    4、在其下创建api接口工程。
    
    • 1

    xuecheng-plus-content-api接口工程的父工程是xuecheng-plus-content,它依赖了xuecheng-plus-base基础工程。

    image-20230906223754101
    
    <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.0modelVersion>
        <parent>
            <artifactId>xuecheng-plus-contentartifactId>
            <groupId>com.xuechenggroupId>
            <version>0.0.1-SNAPSHOTversion>
        parent>
        <artifactId>xuecheng-plus-content-apiartifactId>
        <dependencies>
            <dependency>
                <groupId>com.xuechenggroupId>
                <artifactId>xuecheng-plus-content-serviceartifactId>
                <version>0.0.1-SNAPSHOTversion>
            dependency>
        dependencies>
    project>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
  • 相关阅读:
    MATLAB|热力日历图
    js关于深度克隆问题
    芯科蓝牙BG27开发笔记1-新建示例工程
    R语言绘制韦布尔分布图和泊松(Poisson)分布图,并为二项分布(泊松分布)绘制不同颜色
    发布 .NET 7 MAUI / MAUI Blazor 应用到 Windows 应用商店
    7-20 窗口滑动
    实现协议互通:探索钡铼BL124EC的EtherCAT转Ethernet/IP功能
    基于栅格地图的路径规划(一)基于Matlab二维、三维栅格地图的构建
    ros2工作空间
    Linux操作系统
  • 原文地址:https://blog.csdn.net/qq_47949604/article/details/132906860