(七)整合spring cloud云服务架构 - common-service 项目构建过程

我们将对common-service整个项目进行剖析,将整个构建的流程给记录下来,让更多的关注者来参考学习。

首先在构建spring cloud的common-service之前,我们需要准备的技术:

Maven(项目构建)、Spring Boot、Spring Cloud、微服务概念、去中心化思想、分布式等,针对于common-service的顶级项目,这里我们主要使用Maven来构建,闲话少说,我们直接上代码是最直观的。

1. 创建一个Maven的顶级项目,其中pom.xml文件配置如下:

Xml代码

收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.cloud</groupId>
  7. <artifactId>spring-cloud-starter-parent</artifactId>
  8. <version>Dalston.RELEASE</version>
  9. <relativePath />
  10. </parent>
  11. <groupId>com.ml.honghu</groupId>
  12. <artifactId>particle-commonservice</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <packaging>pom</packaging>
  15. <name>particle-commonservice</name>
  16. <description>particle-commonservice project for Spring Boot</description>
  17. <modules>
  18. <module>particle-commonservice-config</module>
  19. <module>particle-commonservice-eureka</module>
  20. <module>particle-commonservice-mq</module>
  21. <module>particle-commonservice-cache</module>
  22. <module>particle-commonservice-sso</module>
  23. <module>particle-commonservice-apigateway</module>
  24. <module>particle-commonservice-zipkin</module>
  25. <module>particle-commonservice-admin</module>
  26. <module>particle-commonservice-turbine</module>
  27. <module>particle-commonservice-combine</module>
  28. <module>particle-commonservice-sequence</module>
  29. </modules>
  30. <properties>
  31. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  32. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  33. <java.version>1.8</java.version>
  34. <!-- 框架通用包版本设置 -->
  35. <validator.version>5.3.4.Final</validator.version>
  36. <shiro.version>1.2.3</shiro.version>
  37. <druid.version>1.0.26</druid.version>
  38. <mybatis-spring.version>1.2.2</mybatis-spring.version>
  39. <shiro.version>1.2.3</shiro.version>
  40. <druid.version>1.0.11</druid.version>
  41. <ehcache.version>2.6.9</ehcache.version>
  42. <ehcache-web.version>2.0.4</ehcache-web.version>
  43. <sitemesh.version>2.4.2</sitemesh.version>
  44. <activiti.version>5.15.1</activiti.version>
  45. <wink.version>1.4</wink.version>
  46. <sso.client.version>3.4.1</sso.client.version> -->
  47. <!-- 通用工具包版本设置 -->
  48. <slf4j.version>1.7.7</slf4j.version>
  49. <commons-lang3.version>3.3.2</commons-lang3.version>
  50. <commons-io.version>2.4</commons-io.version>
  51. <commons-codec.version>1.9</commons-codec.version>
  52. <commons-fileupload.version>1.3.1</commons-fileupload.version>
  53. <commons-beanutils.version>1.9.1</commons-beanutils.version>
  54. <fastjson.version>1.1.40</fastjson.version>
  55. <xstream.version>1.4.7</xstream.version>
  56. <guava.version>17.0</guava.version>
  57. <dozer.version>5.5.1</dozer.version>
  58. <email.version>1.4.7</email.version>
  59. <poi.version>3.9</poi.version>
  60. <cglib.version>3.2.5</cglib.version>
  61. <!-- aliyun -->
  62. <aliyun-sdk-oss.version>2.6.0</aliyun-sdk-oss.version>
  63. <aliyun-sdk-openservices-ons.version>1.2.7.Final</aliyun-sdk-openservices-ons.version>
  64. <com.ml.honghu.componet.version>0.0.1-SNAPSHOT</com.ml.honghu.componet.version>
  65. <spring-boot-admin.version>1.5.1</spring-boot-admin.version>
  66. <fastjson.version>1.2.35</fastjson.version>
  67. </properties>
  68. <dependencyManagement>
  69. <dependencies>
  70. <!-- spring cloud -->
  71. <dependency>
  72. <groupId>org.springframework.cloud</groupId>
  73. <artifactId>spring-cloud-dependencies</artifactId>
  74. <version>Dalston.RELEASE</version>
  75. <type>pom</type>
  76. <scope>import</scope>
  77. </dependency>
  78. <dependency>
  79. <groupId>org.jasig.cas.client</groupId>
  80. <artifactId>cas-client-core</artifactId>
  81. <version>3.4.1</version>
  82. </dependency>
  83. <dependency>
  84. <groupId>io.springfox</groupId>
  85. <artifactId>springfox-swagger2</artifactId>
  86. <version>2.5.0</version>
  87. </dependency>
  88. <dependency>
  89. <groupId>de.codecentric</groupId>
  90. <artifactId>spring-boot-admin-server</artifactId>
  91. <version>${spring-boot-admin.version}</version>
  92. </dependency>
  93. <dependency>
  94. <groupId>de.codecentric</groupId>
  95. <artifactId>spring-boot-admin-server-ui</artifactId>
  96. <version>${spring-boot-admin.version}</version>
  97. </dependency>
  98. <dependency>
  99. <groupId>de.codecentric</groupId>
  100. <artifactId>spring-boot-admin-server-ui-hystrix</artifactId>
  101. <version>${spring-boot-admin.version}</version>
  102. </dependency>
  103. <dependency>
  104. <groupId>de.codecentric</groupId>
  105. <artifactId>spring-boot-admin-server-ui-turbine</artifactId>
  106. <version>${spring-boot-admin.version}</version>
  107. </dependency>
  108. <dependency>
  109. <groupId>de.codecentric</groupId>
  110. <artifactId>spring-boot-admin-server-ui-login</artifactId>
  111. <version>${spring-boot-admin.version}</version>
  112. </dependency>
  113. <dependency>
  114. <groupId>de.codecentric</groupId>
  115. <artifactId>spring-boot-admin-server-ui-activiti</artifactId>
  116. <version>${spring-boot-admin.version}</version>
  117. </dependency>
  118. <dependency>
  119. <groupId>org.slf4j</groupId>
  120. <artifactId>slf4j-api</artifactId>
  121. <version>1.7.25</version>
  122. </dependency>
  123. <dependency>
  124. <groupId>com.ml.honghu</groupId>
  125. <artifactId>component-base</artifactId>
  126. <version>${com.ml.honghu.componet.version}</version>
  127. </dependency>
  128. <dependency>
  129. <groupId>com.ml.honghu</groupId>
  130. <artifactId>component-redis</artifactId>
  131. <version>${com.ml.honghu.componet.version}</version>
  132. </dependency>
  133. <dependency>
  134. <groupId>com.ml.honghu</groupId>
  135. <artifactId>component-utils</artifactId>
  136. <version>${com.ml.honghu.componet.version}</version>
  137. </dependency>
  138. <dependency>
  139. <groupId>com.ml.honghu</groupId>
  140. <artifactId>component-sequence-api</artifactId>
  141. <version>${com.ml.honghu.componet.version}</version>
  142. </dependency>
  143. <dependency>
  144. <groupId>com.ml.honghu</groupId>
  145. <artifactId>component-admin-ui-zipkin</artifactId>
  146. <version>${com.ml.honghu.componet.version}</version>
  147. </dependency>
  148. <dependency>
  149. <groupId>com.ml.honghu</groupId>
  150. <artifactId>component-admin-ui-route</artifactId>
  151. <version>${com.ml.honghu.componet.version}</version>
  152. </dependency>
  153. <dependency>
  154. <groupId>com.ml.honghu</groupId>
  155. <artifactId>component-zuul-label</artifactId>
  156. <version>${com.ml.honghu.componet.version}</version>
  157. </dependency>
  158. </dependencies>
  159. </dependencyManagement>
  160. </project>

当前的pom.xml文件引入了spring cloud相关版本配置,通用工具版本配置,honghu相关组件配置(因为其他的系统服务项目依赖于相关的组件,组件项目也是后面来创建的)(企业架构源码可以加求球:叁五三陆二肆柒二伍玖)

从现在开始,我这边会将近期研发的spring cloud微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发spring cloud框架的朋友,大家来一起探讨spring cloud架构的搭建过程及如何运用于企业项目。