Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/v5tech/spring-boot-apollo-sample

Demo project for Spring Boot Apollo
https://github.com/v5tech/spring-boot-apollo-sample

apollo spring-boot spring-boot-apollo-sample

Last synced: 4 months ago
JSON representation

Demo project for Spring Boot Apollo

Awesome Lists containing this project

README

        

# spring-boot-apollo-sample
Demo project for Spring Boot Apollo

Spring Boot整合携程Apollo配置中心

## 客户端maven配置

* apollo-client(必须)

```xml

com.ctrip.framework.apollo
apollo-client
0.8.0

```
* spring-boot-starter-actuator 和 spring-cloud-context

```xml

org.springframework.boot
spring-boot-starter-actuator

org.springframework.cloud
spring-cloud-context
1.2.2.RELEASE

```

注意:

1、`apollo-client`为必须配置

2、`spring-boot-starter-actuator` 和 `spring-cloud-context`为可选配置。仅在使用`Spring Cloud`的`@RefreshScope`时所需

## 客户端使用

![](Screenshots/6B4E9E4C-2744-4B76-B1BA-21343CAC0508.png)

* Java Config结合Spring Placeholder方式

详见JavaConfigSample。JavaConfigSample使用`Config API`实现属性值变动实时修改

![](Screenshots/1.gif)

* Spring Boot ConfigurationProperties方式

详见ConfigurationPropertiesSample。

ConfigurationPropertiesSample并没有使用`Config API`实现属性值变动实时修改,而是采用`Spring Cloud`的`@RefreshScope`注解和`/refresh`端点来刷新属性值

![](Screenshots/2.gif)

注:本示例代码所有配置属性在Apollo配置中心修改后立即生效。

# 参考文档

https://github.com/ctripcorp/apollo/wiki/