spring cloud 微服務架構 簡介
阿新 • • 發佈:2017-09-27
session 進行 tell div apach 後來 tro 最新版 maven Spring Cloud
Spring Cloud 包含了多個子項目:
環境準備:
3、 父項目的建立
1、 Spring Cloud 簡介
Spring Cloud是在Spring Boot的基礎上構建的,用於簡化分布式系統構建的工具集,為開發人員提供快速建立分布式系統中的一些常見的模式。
> 例如:配置管理(configuration management),服務發現(service discovery),斷路器(circuit breakers),智能路由( intelligent routing),微代理(micro-proxy),控制總線(control bus),一次性令牌( one-time tokens),全局鎖(global locks),領導選舉(leadership election),分布式會話(distributed sessions),集群狀態(cluster state)。
> 例如:Spring Cloud Config、Spring Cloud Netflix等
Spring Cloud 項目主頁:[http://projects.spring.io/spring-cloud/](http://projects.spring.io/spring-cloud/)
Talk is cheap, show me the code.下面我們將以代碼與講解結合的方式,為大家講解Spring Cloud中的各種組件。
2、準備工作
* 技術儲備:
| 所需技能 | 備註 | | ----------- | ------------------------------- | | Java | | | Maven | 文章涉及到大量的代碼,均使用Maven構建 | | Spring Boot | Spring Cloud是在Spring Boot基礎上構建的 |
| 工具 | 版本或描述 | | ----- | -------------------------------- | | JDK | 1.8 | | IDE | STS 或者 IntelliJ IDEA,本教程使用的是STS. | | Maven | 3.x |
* 本課程所使用的軟件及版本:
| 使用到的軟件 | 版本號 | 是否最新版本 |
| ------------ | ------------- | ------ | | Spring Boot | 1.4.0.RELEASE | 是 | | Spring Cloud | Brixton.SR5 | 是 |
在進入主題之前,我們首先創建一個父項目(spring-cloud-microservice-study),這樣可以對項目中的Maven依賴進行統一的管理。
xml
<?xml version="1.0" encoding="UTF-8"?> <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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.xujin.study</groupId> <artifactId>microservice-spring-cloud</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.0.RELEASE</version> </parent> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Brixton.SR5</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
1. 筆者講解采用最新的Spring Boot 和Spring Cloud進行講解,其中可能涉及到部分新特性,筆者盡量指出,同時筆者能力有限,如有理解不到位的地方,還請各位看客指出,定在第一時間進行修正。 2. Spring Cloud版本並不是傳統的使用數字的方式標識,而是使用例如:Angel、Brixton、Camden...等等倫敦的地名來命名版本,版本的先後順序大家可能已經猜到了,就是使用字母表的先後來標識的。筆者在咨詢過Spring Cloud的主要貢獻者之一Josh Long之後已經確認。
spring cloud 微服務架構 簡介