Spring cloud

跳转至: 导航搜索

https://springcloud.cc/spring-cloud-dalston.html https://spring.io/projects/spring-cloud


使用Spring Cloud和Docker构建微服务 使用Spring Cloud和Docker构建微服务源代码 中文文档 Eureka高可用 服务的部署和发布策略

  • Angel-->Brixton-->Camden
  1. 最初的Angel版本相对来说拥有的子项目较少
  2. Brixton的发布子项目更为稳定
  3. Camden则更为前瞻。
  4. 当一个版本的Spring Cloud项目的发布内容积累到临界点或者一个严重bug解决可用后,就会发布一个“service releases”版本,简称SR1,SR2.....版本,其中X是一个递增数字


Spring Cloud Config

Spring Cloud Config Mapped Spring Cloud Netflix Eureka: 多网卡环境下Eureka服务注册IP选择问题

1、config 默认Git加载 通过spring.cloud.config.server.git.uri指定配置信息存储的git地址,比如:https://github.com/spring-cloud-samples/config-repo


### config server native

3、加载 本地物理环境


4、加载svn环境 http://localhost:8888/{application}/{profile}/{label},比如:http://localhost:8888/dmeo/development/trunk

## config server svn

特别注意 svn 环境 需要 引入 SVN jar包



  • 服务端

Centralized external configuration management backed by a git repository. The configuration resources map directly to Spring `Environment` but could be used by non-Spring applications if desired.

  1. spring.cloud.config.server.git.basedir or spring.cloud.config.server.svn.basedir
  2. spring.profiles.active=native 可以开启文件方式配置
  3. The default value of the searchLocations is identical to a local Spring Boot application (so [classpath:/, classpath:/config, file:./, file:./config]). This does not expose the application.properties from the server to all clients because any property sources present in the server are removed before being sent to the client.
  4. spring.cloud.config.server.native.searchLocations 设置文件方式是的文件路径
  5. absolute paths in Windows require an extra "/", e.g. file:///${user.home}/config-repo window环境下需要额外的/
  6. 建议文件形式仅仅用于开发模式,生产环境下不是每个应用都能使用一个路径A filesystem backend is great for getting started quickly and for testing. To use it in production you need to be sure that the file system is reliable, and shared across all instances of the Config Server.
  7. The search locations也能支持 {application}, {profile} and {label} where the "application" 对应 spring.config.name , "profile" 对应 active profile and "label" 是git的一个可选项 (defaults to "master".)
  8. /{application}/{profile}[/{label}]
  9. Multiple Properties Sources secret/myApp,dev secret/application,dev with properties in the first path in the list taking priority over the others
  10. application*文件命名的配置文件能被所有的client获取.With file-based (i.e. git, svn and native) repositories, resources with file names in application* are shared between all client applications (so application.properties, application.yml, application-*.properties etc.). You can use resources with these file names to configure global defaults and have them overridden by application-specific files as necessary
  11. 可以通过{cipher}标识字符串是加密过的.If the remote property sources contain encrypted content (values starting with {cipher})
  12. viz eureka.instance.[nonSecurePortEnabled,securePortEnabled]=[false,true]
  13. 服务端可以引用spring-boot-starter-security后通过security.user.password设置权限密码,默认用户为user
  14. application.properties spring.datasource.username: dbuser spring.datasource.password: {cipher}FKSAJDFGYOS8F7GLHAKERGFHLSAJ {cipher}标识后面的串需要解密
  15. 加密curl localhost:8888/encrypt -d mysecret
  16. 解密 curl localhost:8888/decrypt -d 682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda
  17. 秘钥加密......
  18. 如果你想客户端自己解密,不用服务端设置解密,设置spring.cloud.config.server.encrypt.enabled=false
  19. spring.cloud.config.server.prefix可以设置服务的context
  20. spring.cloud.config.server.bootstrap=true可以关闭从远程服务器读取配置

POST to /env to update the Environment and rebind @ConfigurationProperties and log levels

/refresh for re-loading the boot strap context and refreshing the @RefreshScope beans

/restart for closing the ApplicationContext and restarting it (disabled by default)

/pause and /resume for calling the Lifecycle methods (stop() and start() on the ApplicationContext)

  • 客户端
  1. spring.cloud.config.uri 指定配置服务器地址 https://user:secret@myconfig.mycompany.com或者uri: https://myconfig.mycompany.com username: user password: secret The spring.cloud.config.password and spring.cloud.config.username values override anything that is provided in the URI.
  2. spring.cloud.config.failFast=true 如果没找打配置服务器仍然启动应用
  3. eureka.instance.metadataMap 可以指定连接到配置服务器的更多值 user: osufhalskjrtl password: lviuhlszvaorhvlo5847 configPath: /config
  4. Config Client Retry
  5. spring.cloud.config.label=myfeature,develop)

Spring Cloud Netflix


Integration with various Netflix OSS components (Eureka, Hystrix, Zuul, Archaius, etc.).

  • Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans
  • Service Discovery: an embedded Eureka server can be created with declarative Java configuration
  • Circuit Breaker: Hystrix clients can be built with a simple annotation-driven method decorator
  • Circuit Breaker: embedded Hystrix dashboard with declarative Java configuration
  • Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations
  • Client Side Load Balancer: Ribbon
  • External Configuration: a bridge from the Spring Environment to Archaius (enables native configuration of Netflix components using Spring Boot conventions)
  • Router and Filter: automatic regsitration of Zuul filters, and a simple convention over configuration approach to reverse proxy creation

Spring Cloud eureka

HTTP basic authentication is automatically added to your eureka client if one of the eureka.client.serviceUrl.defaultZone URLs has credentials embedded in it (curl style, as follows: http://user:password@localhost:8761/eureka). For more complex needs, you can create a @Bean of type DiscoveryClientOptionalArgs and inject ClientFilter instances into it, all of which is applied to the calls from the client to the server.

Spring Cloud gateway


Spring Cloud Bus

An event bus for linking services and service instances together with distributed messaging. Useful for propagating state changes across a cluster (e.g. config change events).

Spring Cloud for Cloud Foundry

Integrates your application with Pivotal Cloudfoundry. Provides a service discovery implementation and also makes it easy to implement SSO and OAuth2 protected resources, and also to create a Cloudfoundry service broker.

Spring Cloud Cloud Foundry Service Broker=== Provides a starting point for building a service broker that manages a Cloud Foundry managed service.

Spring Cloud Cluster

Leadership election and common stateful patterns with an abstraction and implementation for Zookeeper, Redis, Hazelcast, Consul.

Spring Cloud Consul

Service discovery and configuration management with Hashicorp Consul.

Spring Cloud Security

Provides support for load-balanced OAuth2 rest client and authentication header relays in a Zuul proxy.

Spring Cloud Sleuth=== Distributed tracing for Spring Cloud applications, compatible with Zipkin, HTrace and log-based (e.g. ELK) tracing.

Spring Cloud Data Flow

A cloud native programming and operating model for composable data microservices on a structured platform.

Spring Cloud Stream

Messaging microservices with Redis, Rabbit or Kafka. Simple declarative model to send and receive messages in a Spring Cloud app.

Spring Cloud Stream Modules

Spring Cloud Stream Modules can be used with Spring Cloud Stream to create, build, and scale message-driven data microservices.

Spring Cloud Task

Short lived microservices. Simple declarative for adding both functional and non-functional features to Spring Boot apps.

Spring Cloud Zookeeper

Service discovery and configuration management with Apache Zookeeper.

Spring Cloud for Amazon Web Services

Easy integration with hosted Amazon Web Services. It offers a convenient way to interact with AWS provided services using well-known Spring idioms and APIs, such as the messaging or caching API. Developers can build their application around the hosted services without having to care about infrastructure or maintenance.

Spring Cloud Connectors

Makes it easy for PaaS applications in a variety of platforms to connect to backend services like databases and message brokers (the project formerly known as "Spring Cloud").

Spring Cloud Starters

Spring Boot-style starter projects to ease dependency management for consumers of Spring Cloud. (Discontinued as a project and merged with the other projects after Angel.SR2.)

Spring Cloud CLI

Spring Boot CLI plugin for creating Spring Cloud component applications quickly in Groovy spring cloud dependency


was unable to refresh its cache! status = Cannot execute request on any known server

config server的配置文件中不能有 eureka.client.serviceUrl.defaultZone的配置,原因不明


Unable to find a single main class from the following candidates

原来这个错误是因为maven在执行打包的时候会查找项目中的main方法,并设置为Spring boot 生成jar包的启动入口,但此时有多个main方法,maven插件就无所适从了。因此出现此异常。