spring-cloud-config-refresh-listener

spring cloud config refresh listener

License

License

MIT
Categories

Categories

config Application Layer Libs Configuration
GroupId

GroupId

com.github.yugj
ArtifactId

ArtifactId

spring-cloud-config-refresh-listener
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

pom
Description

Description

spring-cloud-config-refresh-listener
spring cloud config refresh listener
Project URL

Project URL

https://github.com/yugj/spring-cloud-config-refresh-listener
Source Code Management

Source Code Management

https://github.com/yugj/spring-cloud-config-refresh-listener

Download spring-cloud-config-refresh-listener

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.yugj/spring-cloud-config-refresh-listener/ -->
<dependency>
    <groupId>com.github.yugj</groupId>
    <artifactId>spring-cloud-config-refresh-listener</artifactId>
    <version>2.0.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.yugj/spring-cloud-config-refresh-listener/
implementation 'com.github.yugj:spring-cloud-config-refresh-listener:2.0.0'
// https://jarcasting.com/artifacts/com.github.yugj/spring-cloud-config-refresh-listener/
implementation ("com.github.yugj:spring-cloud-config-refresh-listener:2.0.0")
'com.github.yugj:spring-cloud-config-refresh-listener:pom:2.0.0'
<dependency org="com.github.yugj" name="spring-cloud-config-refresh-listener" rev="2.0.0">
  <artifact name="spring-cloud-config-refresh-listener" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.github.yugj', module='spring-cloud-config-refresh-listener', version='2.0.0')
)
libraryDependencies += "com.github.yugj" % "spring-cloud-config-refresh-listener" % "2.0.0"
[com.github.yugj/spring-cloud-config-refresh-listener "2.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • config-refresh-listener-core
  • config-refresh-listener-demo

spring-cloud-config-refresh-listener

spring cloud 监听特定配置变化
spring cloud config refresh listener

使用说明

引入依赖

<dependency>
    <groupId>com.github.yugj</groupId>
    <artifactId>config-refresh-listener-core</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

启动类添加注解

   @SpringBootApplication
   @EnableConfigRefreshListener
   public class ConfigListenerDemoStarter {
       public static void main(String[] args) {
           SpringApplication application = new SpringApplication(ConfigListenerDemoStarter.class);
           application.run(args).start();
       }
   }

监听关注的配置变化(这边直接采用原生el表达式匹配事件)

    @EventListener(condition = "#event.key eq 'sys.log.root'")
    void handleConditionalListener(ConfigRefreshEvent event) {
        // 业务逻辑 balabala
        System.out.println("handleConditionalListener event key :" + event.getKey()
        + ", before :" + event.getBeforeRefresh()
        + ", after :" + event.getAfterRefresh());
    }

版本兼容

springboot版本 spring-cloud-config-refresh-listener
1.x 1.0.0
2.x 2.0.0

Config 组件支持

  • spring cloud config
  • alibaba nacos
  • apollo (待测试)

Versions

Version
2.0.0