实践Spring Cloud

Spring Cloud构建在Spring Boot之上,提供了微服务体系和架构等相关的管理,例如:服务治理、配置管理等。Spring Cloud Reference Manual

依赖

版本

1
2
3
<properties>
	<spring-cloud.version>Dalston.SR4</spring-cloud.version>
</properties>

spring cloud依赖管理

1
2
3
4
5
6
7
8
9
10
11
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-dependencies</artifactId>
      <version>${spring-cloud.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

spring-cloud-dependencies继承spring-cloud-dependencies-parent

Spring Cloud Context

Spring Cloud Context provides utilities and special services for the ApplicationContext of a Spring Cloud application (bootstrap context, encryption, refresh scope and environment endpoints)

bootstrap.properties/yml

Spring Cloud Commons

Spring Cloud Commons is a set of abstractions and common classes used in different Spring Cloud implementations (eg. Spring Cloud Netflix vs. Spring Cloud Consul).

@SpringCloudApplication

1
2
3
4
5
6
7
8
9
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
public @interface SpringCloudApplication {
}

@SpringCloudApplication包含了@SpringBootApplication@EnableDiscoveryClient@EnableCircuitBreaker这三个注解。

参考

Spring Cloud中国社区

Spring Cloud中文网

《Spring Cloud微服务实战》,源码地址(Github)

《spring cloud与Docker微服务架构实战》,源代码(Github)

《重新定义Spring Cloud》,源码地址(Github)

《Spring Cloud微服务架构开发实战》,源代码(Github)