创建项目结构:
    父级
    image.png
    在父级创建Mould:
    image.png
    image.png
    image.png
    在该Module下又下两个Module:
    image.png
    image.png

    项目创建完毕:
    image.png
    admin: 后台
    common: 公共的类,配置,工具类
    iaas: 网关和制授权
    res: 资源
    sys: 系统管理,用户
    data-analysis: 系统统计
    third:上报管理(第三方)
    oa: 在线OA

    把所有服务的service的pom.xml都引用自己服务的common模块:
    1.先在父类把所有的包都打包:
    image.png

    把所有的版本号都定义在父类的pom.xml:
    image.png

    1. <properties>
    2. <java.version>1.8</java.version>
    3. <spring-cloud.version>Hoxton.SR3</spring-cloud.version>
    4. <com-alibaba-cloud.version>2.2.0.RELEASE</com-alibaba-cloud.version>
    5. <mybatis-plus-boot-stater.version>3.3.2</mybatis-plus-boot-stater.version>
    6. <druid-boot-stater.version>1.1.23</druid-boot-stater.version>
    7. <redisson-spring-boot-starter.version>3.13.3</redisson-spring-boot-starter.version>
    8. <jetcache-starter-redis.version>2.6.0</jetcache-starter-redis.version>
    9. <disruptor.version>3.4.2</disruptor.version>
    10. <org.mapstruct.version>1.4.0.Beta3</org.mapstruct.version>
    11. <commons-beanutils.version>1.9.4</commons-beanutils.version>
    12. <swagger-annotations.version>1.5.20</swagger-annotations.version>
    13. <googleauth.version>1.1.5</googleauth.version>
    14. <net.sf.supercsv.version>2.4.0</net.sf.supercsv.version>
    15. <springside-utils.version>5.0.0-RC1</springside-utils.version>
    16. <aliyun-sdk-oss.version>3.1.0</aliyun-sdk-oss.version>
    17. <aliyun-java-sdk-core.version>4.0.3</aliyun-java-sdk-core.version>
    18. <aliyun-java-sdk-dm.version>3.3.1</aliyun-java-sdk-dm.version>
    19. <joda-time.version>2.10</joda-time.version>
    20. <okhttp.version>3.11.0</okhttp.version>
    21. <okio.version>1.15.0</okio.version>
    22. </properties>
    1. <dependencies>
    2. <dependency>
    3. <groupId>org.projectlombok</groupId>
    4. <artifactId>lombok</artifactId>
    5. </dependency>
    6. <!-- https://mvnrepository.com/artifact/io.swagger/swagger-annotations -->
    7. <dependency>
    8. <groupId>io.swagger</groupId>
    9. <artifactId>swagger-annotations</artifactId>
    10. </dependency>
    11. <dependency>
    12. <groupId>com.baomidou</groupId>
    13. <artifactId>mybatis-plus-annotation</artifactId>
    14. </dependency>
    15. <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
    16. <dependency>
    17. <groupId>com.fasterxml.jackson.core</groupId>
    18. <artifactId>jackson-annotations</artifactId>
    19. </dependency>
    20. </dependencies>
    21. <dependencyManagement>
    22. <dependencies>
    23. <dependency>
    24. <groupId>org.springframework.cloud</groupId>
    25. <artifactId>spring-cloud-dependencies</artifactId>
    26. <version>${spring-cloud.version}</version>
    27. <type>pom</type>
    28. <scope>import</scope>
    29. </dependency>
    30. <dependency>
    31. <groupId>com.alibaba.cloud</groupId>
    32. <artifactId>spring-cloud-alibaba-dependencies</artifactId>
    33. <version>${com-alibaba-cloud.version}</version>
    34. <type>pom</type>
    35. <scope>import</scope>
    36. </dependency>
    37. <dependency>
    38. <groupId>io.swagger</groupId>
    39. <artifactId>swagger-annotations</artifactId>
    40. <version>${swagger-annotations.version}</version>
    41. </dependency>
    42. <dependency>
    43. <groupId>com.baomidou</groupId>
    44. <artifactId>mybatis-plus-boot-starter</artifactId>
    45. <version>${mybatis-plus-boot-stater.version}</version>
    46. </dependency>
    47. <dependency>
    48. <groupId>com.baomidou</groupId>
    49. <artifactId>mybatis-plus-annotation</artifactId>
    50. <version>${mybatis-plus-boot-stater.version}</version>
    51. </dependency>
    52. <!-- https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter -->
    53. <dependency>
    54. <groupId>com.alibaba</groupId>
    55. <artifactId>druid-spring-boot-starter</artifactId>
    56. <version>${druid-boot-stater.version}</version>
    57. </dependency>
    58. <dependency>
    59. <groupId>commons-beanutils</groupId>
    60. <artifactId>commons-beanutils</artifactId>
    61. <version>${commons-beanutils.version}</version>
    62. </dependency>
    63. <!-- https://mvnrepository.com/artifact/org.redisson/redisson-spring-boot-starter -->
    64. <dependency>
    65. <groupId>org.redisson</groupId>
    66. <artifactId>redisson-spring-boot-starter</artifactId>
    67. <version>${redisson-spring-boot-starter.version}</version>
    68. </dependency>
    69. <!-- https://mvnrepository.com/artifact/com.alicp.jetcache/jetcache-starter-redis -->
    70. <dependency>
    71. <groupId>com.alicp.jetcache</groupId>
    72. <artifactId>jetcache-starter-redis</artifactId>
    73. <version>${jetcache-starter-redis.version}</version>
    74. </dependency>
    75. <!-- https://mvnrepository.com/artifact/com.lmax/disruptor -->
    76. <dependency>
    77. <groupId>com.lmax</groupId>
    78. <artifactId>disruptor</artifactId>
    79. <version>${disruptor.version}</version>
    80. </dependency>
    81. <dependency>
    82. <groupId>io.springfox</groupId>
    83. <artifactId>springfox-swagger2</artifactId>
    84. <version>${swagger2.version}</version>
    85. </dependency>
    86. <dependency>
    87. <groupId>io.springfox</groupId>
    88. <artifactId>springfox-swagger-ui</artifactId>
    89. <version>${swagger2.version}</version>
    90. </dependency>
    91. <!--mapStruct依赖-->
    92. <dependency>
    93. <groupId>org.mapstruct</groupId>
    94. <artifactId>mapstruct-jdk8</artifactId>
    95. <version>${org.mapstruct.version}</version>
    96. </dependency>
    97. <dependency>
    98. <groupId>org.mapstruct</groupId>
    99. <artifactId>mapstruct-processor</artifactId>
    100. <version>${org.mapstruct.version}</version>
    101. <scope>provided</scope>
    102. </dependency>
    103. <dependency>
    104. <groupId>net.sf.supercsv</groupId>
    105. <artifactId>super-csv</artifactId>
    106. <version>${net.sf.supercsv.version}</version>
    107. </dependency>
    108. <dependency>
    109. <groupId>io.springside</groupId>
    110. <artifactId>springside-utils</artifactId>
    111. <version>${springside-utils.version}</version>
    112. </dependency>
    113. <dependency>
    114. <groupId>org.flywaydb</groupId>
    115. <artifactId>flyway-core</artifactId>
    116. <version>${flyway.version}</version>
    117. </dependency>
    118. <dependency>
    119. <groupId>joda-time</groupId>
    120. <artifactId>joda-time</artifactId>
    121. <version>${joda-time.version}</version>
    122. </dependency>
    123. <dependency>
    124. <groupId>com.squareup.okhttp3</groupId>
    125. <artifactId>okhttp</artifactId>
    126. <version>${okhttp.version}</version>
    127. </dependency>
    128. <dependency>
    129. <groupId>com.squareup.okio</groupId>
    130. <artifactId>okio</artifactId>
    131. <version>${okio.version}</version>
    132. </dependency>
    133. <dependency>
    134. <groupId>com.aliyun.oss</groupId>
    135. <artifactId>aliyun-sdk-oss</artifactId>
    136. <version>${aliyun-sdk-oss.version}</version>
    137. </dependency>
    138. <dependency>
    139. <groupId>com.aliyun</groupId>
    140. <artifactId>aliyun-java-sdk-core</artifactId>
    141. <version>${aliyun-java-sdk-core.version}</version>
    142. </dependency>
    143. <dependency>
    144. <groupId>com.aliyun</groupId>
    145. <artifactId>aliyun-java-sdk-dm</artifactId>
    146. <version>${aliyun-java-sdk-dm.version}</version>
    147. </dependency>
    148. </dependencies>
    149. </dependencyManagement>

    1、在Maven中dependencyManagement的作用其实相当于一个对所依赖jar包进行版本管理的管理器。
    2、pom.xml文件中,jar的版本判断的两种途径
    1)如果dependencies里的dependency自己没有声明version元素,那么maven就会到dependencyManagement里面去找有没有对该artifactId和groupId进行过版本声明,如果有,就继承它,如果没有就会报错,告诉你必须为dependency声明一个version。
    2)如果dependencies中的dependency声明了version,那么无论dependencyManagement中有无对该jar的version声明,都以dependency里的version为准。
    3、1)dependencies即使在子项目中不写该依赖项,那么子项目仍然会从父项目中继承该依赖项(全部继承)
    2)dependencyManagement里只是声明依赖,并不实现引入,因此子项目需要显示的声明需要用的依赖。如果不在子项目中声明依赖,是不会从父项目中继承下来的;只有在子项目中写了该依赖项,并且没有指定具体版本,才会从父项目中继承该项,并且version和scope都读取自父pom;另外如果子项目中指定了版本号,那么会使用子项目中指定的jar版本。