咱们将对common-service整个我的项目进行分析,将整个构建的流程给记录下来,让更多的关注者来参考学习。
首先在构建spring cloud的common-service之前,咱们须要筹备的技术:
Maven(我的项目构建)、Spring Boot、Spring Cloud、微服务概念、去中心化思维、分布式等,针对于common-service的顶级我的项目,这里咱们次要应用Maven来构建,闲话少说,咱们间接上代码是最直观的。
- 创立一个Maven的顶级我的项目,其中pom.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> 12. <groupId>com.ml.honghu</groupId> 13. <artifactId>particle-commonservice</artifactId> 14. <version>0.0.1-SNAPSHOT</version> 15. <packaging>pom</packaging> 17. <name>particle-commonservice</name> 18. <description>particle-commonservice project for Spring Boot</description> 20. <modules> 21. <module>particle-commonservice-config</module> 22. <module>particle-commonservice-eureka</module> 23. <module>particle-commonservice-mq</module> 24. <module>particle-commonservice-cache</module> 25. <module>particle-commonservice-sso</module> 26. <module>particle-commonservice-apigateway</module> 27. <module>particle-commonservice-zipkin</module> 28. <module>particle-commonservice-admin</module> 29. <module>particle-commonservice-turbine</module> 30. <module>particle-commonservice-combine</module> 31. <module>particle-commonservice-sequence</module> 32. </modules> 34. <properties> 35. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 36. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 37. <java.version>1.8</java.version> 39. <!-- 框架通用包版本设置 --> 40. <validator.version>5.3.4.Final</validator.version> 41. <shiro.version>1.2.3</shiro.version> 42. <druid.version>1.0.26</druid.version> 43. <mybatis-spring.version>1.2.2</mybatis-spring.version> 44. <shiro.version>1.2.3</shiro.version> 45. <druid.version>1.0.11</druid.version> 46. <ehcache.version>2.6.9</ehcache.version> 47. <ehcache-web.version>2.0.4</ehcache-web.version> 48. <sitemesh.version>2.4.2</sitemesh.version> 49. <activiti.version>5.15.1</activiti.version> 50. <wink.version>1.4</wink.version> 51. <sso.client.version>3.4.1</sso.client.version> --> 53. <!-- 通用工具包版本设置 --> 54. <slf4j.version>1.7.7</slf4j.version> 55. <commons-lang3.version>3.3.2</commons-lang3.version> 56. <commons-io.version>2.4</commons-io.version> 57. <commons-codec.version>1.9</commons-codec.version> 58. <commons-fileupload.version>1.3.1</commons-fileupload.version> 59. <commons-beanutils.version>1.9.1</commons-beanutils.version> 60. <fastjson.version>1.1.40</fastjson.version> 61. <xstream.version>1.4.7</xstream.version> 62. <guava.version>17.0</guava.version> 63. <dozer.version>5.5.1</dozer.version> 64. <email.version>1.4.7</email.version> 65. <poi.version>3.9</poi.version> 66. <cglib.version>3.2.5</cglib.version> 68. <!-- aliyun --> 69. <aliyun-sdk-oss.version>2.6.0</aliyun-sdk-oss.version> 70. <aliyun-sdk-openservices-ons.version>1.2.7.Final</aliyun-sdk-openservices-ons.version> 71. <com.ml.honghu.componet.version>0.0.1-SNAPSHOT</com.ml.honghu.componet.version> 72. <spring-boot-admin.version>1.5.1</spring-boot-admin.version> 73. <fastjson.version>1.2.35</fastjson.version> 74. </properties> 76. <dependencyManagement> 77. <dependencies> 79. <!-- spring cloud --> 80. <dependency> 81. <groupId>org.springframework.cloud</groupId> 82. <artifactId>spring-cloud-dependencies</artifactId> 83. <version>Dalston.RELEASE</version> 84. <type>pom</type> 85. <scope>import</scope> 86. </dependency> 88. <dependency> 89. <groupId>org.jasig.cas.client</groupId> 90. <artifactId>cas-client-core</artifactId> 91. <version>3.4.1</version> 92. </dependency> 94. <dependency> 95. <groupId>io.springfox</groupId> 96. <artifactId>springfox-swagger2</artifactId> 97. <version>2.5.0</version> 98. </dependency> 99. <dependency> 100. <groupId>de.codecentric</groupId> 101. <artifactId>spring-boot-admin-server</artifactId> 102. <version>${spring-boot-admin.version}</version> 103. </dependency> 104. <dependency> 105. <groupId>de.codecentric</groupId> 106. <artifactId>spring-boot-admin-server-ui</artifactId> 107. <version>${spring-boot-admin.version}</version> 108. </dependency> 109. <dependency> 110. <groupId>de.codecentric</groupId> 111. <artifactId>spring-boot-admin-server-ui-hystrix</artifactId> 112. <version>${spring-boot-admin.version}</version> 113. </dependency> 114. <dependency> 115. <groupId>de.codecentric</groupId> 116. <artifactId>spring-boot-admin-server-ui-turbine</artifactId> 117. <version>${spring-boot-admin.version}</version> 118. </dependency> 119. <dependency> 120. <groupId>de.codecentric</groupId> 121. <artifactId>spring-boot-admin-server-ui-login</artifactId> 122. <version>${spring-boot-admin.version}</version> 123. </dependency> 124. <dependency> 125. <groupId>de.codecentric</groupId> 126. <artifactId>spring-boot-admin-server-ui-activiti</artifactId> 127. <version>${spring-boot-admin.version}</version> 128. </dependency> 129. <dependency> 130. <groupId>org.slf4j</groupId> 131. <artifactId>slf4j-api</artifactId> 132. <version>1.7.25</version> 133. </dependency> 134. <dependency> 135. <groupId>com.ml.honghu</groupId> 136. <artifactId>component-base</artifactId> 137. <version>${com.ml.honghu.componet.version}</version> 138. </dependency> 139. <dependency> 140. <groupId>com.ml.honghu</groupId> 141. <artifactId>component-redis</artifactId> 142. <version>${com.ml.honghu.componet.version}</version> 143. </dependency> 144. <dependency> 145. <groupId>com.ml.honghu</groupId> 146. <artifactId>component-utils</artifactId> 147. <version>${com.ml.honghu.componet.version}</version> 148. </dependency> 149. <dependency> 150. <groupId>com.ml.honghu</groupId> 151. <artifactId>component-sequence-api</artifactId> 152. <version>${com.ml.honghu.componet.version}</version> 153. </dependency> 154. <dependency> 155. <groupId>com.ml.honghu</groupId> 156. <artifactId>component-admin-ui-zipkin</artifactId> 157. <version>${com.ml.honghu.componet.version}</version> 158. </dependency> 159. <dependency> 160. <groupId>com.ml.honghu</groupId> 161. <artifactId>component-admin-ui-route</artifactId> 162. <version>${com.ml.honghu.componet.version}</version> 163. </dependency> 164. <dependency> 165. <groupId>com.ml.honghu</groupId> 166. <artifactId>component-zuul-label</artifactId> 167. <version>${com.ml.honghu.componet.version}</version> 168. </dependency> 169. </dependencies> 170. </dependencyManagement> 171. </project>
以后的pom.xml文件引入了spring cloud相干版本配置,通用工具版本配置,honghu相干组件配置(因为其余的零碎服务项目依赖于相干的组件,组件我的项目也是前面来创立的)(企业架构源码能够加求球:叁五三陆二肆柒二伍玖)
从当初开始,我这边会将近期研发的spring cloud微服务云架构的搭建过程和精华记录下来,帮忙更多有趣味研发spring cloud框架的敌人,大家来一起探讨spring cloud架构的搭建过程及如何使用于企业我的项目。