我们将对common-service整个项目进行剖析,将整个构建的流程给记录下来,让更多的关注者来参考学习。
首先在构建spring cloud的common-service之前,我们需要准备的技术:
Maven(项目构建)、Spring Boot、Spring Cloud、微服务概念、去中心化思想、分布式等,针对于common-service的顶级项目,这里我们主要使用Maven来构建,闲话少说,我们直接上代码是最直观的。
1. 创建一个Maven的顶级项目,其中pom.xml文件配置如下:
Xml代码
4.0.0xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
org.springframework.cloud
spring-cloud-starter-parent
Dalston.RELEASE
com.ml.honghu
particle-commonservice
0.0.1-SNAPSHOT
pom
particle-commonservice
particle-commonservice project for Spring Boot
particle-commonservice-config
particle-commonservice-eureka
particle-commonservice-mq
particle-commonservice-cache
particle-commonservice-sso
particle-commonservice-apigateway
particle-commonservice-zipkin
particle-commonservice-admin
particle-commonservice-turbine
particle-commonservice-combine
particle-commonservice-sequence
Final
org.springframework.cloud
spring-cloud-dependencies
Dalston.RELEASE
pom
import
org.jasig.cas.client
cas-client-core
io.springfox
springfox-swagger2
de.codecentric
spring-boot-admin-server
${spring-boot-admin.version}
de.codecentric
spring-boot-admin-server-ui
${spring-boot-admin.version}
de.codecentric
spring-boot-admin-server-ui-hystrix
${spring-boot-admin.version}
de.codecentric
spring-boot-admin-server-ui-turbine
${spring-boot-admin.version}
de.codecentric
spring-boot-admin-server-ui-login
${spring-boot-admin.version}
de.codecentric
spring-boot-admin-server-ui-activiti
${spring-boot-admin.version}
org.slf4j
slf4j-api
com.ml.honghu
component-base
${com.ml.honghu.componet.version}
com.ml.honghu
component-redis
${com.ml.honghu.componet.version}
com.ml.honghu
component-utils
${com.ml.honghu.componet.version}
com.ml.honghu
component-sequence-api
${com.ml.honghu.componet.version}
com.ml.honghu
component-admin-ui-zipkin
${com.ml.honghu.componet.version}
com.ml.honghu
component-admin-ui-route
${com.ml.honghu.componet.version}
com.ml.honghu
component-zuul-label
${com.ml.honghu.componet.version}
当前的pom.xml文件引入了spring cloud相关版本配置,通用工具版本配置,honghu相关组件配置(因为其他的系统服务项目依赖于相关的组件,组件项目也是后面来创建的)
从现在开始,我这边会将近期研发的spring cloud微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发spring cloud框架的朋友,大家来一起探讨spring cloud架构的搭建过程及如何运用于企业项目。源码来源