From 7cfff1ade4fc8bdd53dbd4e2b9634bd238f56625 Mon Sep 17 00:00:00 2001
From: buildmaster @RefreshScope
or specify the classname under the property key
-spring.cloud.refresh.extra-refreshable.
Refresh scope beans are lazy proxies that initialize when they are used (that is, when a method is called), and the scope acts as a cache of initialized values.
+spring.cloud.refresh.extra-refreshable.
![]() | Important |
|---|---|
If you create a |
Refresh scope beans are lazy proxies that initialize when they are used (that is, when a method is called), and the scope acts as a cache of initialized values. To force a bean to re-initialize on the next method call, you must invalidate its cache entry.
The RefreshScope is a bean in the context and has a public refreshAll() method to refresh all beans in the scope by clearing the target cache.
The /refresh endpoint exposes this functionality (over HTTP or JMX).
To refresh an individual bean by name, there is also a refresh(String) method.
To expose the /refresh endpoint, you need to add following configuration to your application:
management: diff --git a/single/spring-cloud-commons.html b/single/spring-cloud-commons.html index 04a75d24..8fec4227 100644 --- a/single/spring-cloud-commons.html +++ b/single/spring-cloud-commons.html @@ -80,7 +80,9 @@ Then, the next time something borrows a connection from the pool, it gets one wi annotation on some beans which can be only initialized once. If a bean is "immutable", you will have to either annotate the bean with@RefreshScopeor specify the classname under the property key -spring.cloud.refresh.extra-refreshable.Refresh scope beans are lazy proxies that initialize when they are used (that is, when a method is called), and the scope acts as a cache of initialized values. +
spring.cloud.refresh.extra-refreshable.
Important If you create a
DataSourcebean yourself and the implementation is aHikariDataSource, return the +most specific type, in this caseHikariDataSource. Otherwise, you will need to set +spring.cloud.refresh.extra-refreshable=javax.sql.DataSource.Refresh scope beans are lazy proxies that initialize when they are used (that is, when a method is called), and the scope acts as a cache of initialized values. To force a bean to re-initialize on the next method call, you must invalidate its cache entry.
The
RefreshScopeis a bean in the context and has a publicrefreshAll()method to refresh all beans in the scope by clearing the target cache. The/refreshendpoint exposes this functionality (over HTTP or JMX). To refresh an individual bean by name, there is also arefresh(String)method.To expose the
/refreshendpoint, you need to add following configuration to your application:management: diff --git a/spring-cloud-commons.xml b/spring-cloud-commons.xml index 3a12bfa5..195ad30b 100644 --- a/spring-cloud-commons.xml +++ b/spring-cloud-commons.xml @@ -194,6 +194,11 @@ annotation on some beans which can be only initialized once. If a bean is "immutable", you will have to either annotate the bean with@RefreshScope or specify the classname under the property keyspring.cloud.refresh.extra-refreshable . ++ If you create a +DataSource bean yourself and the implementation is aHikariDataSource , return the +most specific type, in this caseHikariDataSource . Otherwise, you will need to set +spring.cloud.refresh.extra-refreshable=javax.sql.DataSource .Refresh scope beans are lazy proxies that initialize when they are used (that is, when a method is called), and the scope acts as a cache of initialized values. To force a bean to re-initialize on the next method call, you must invalidate its cache entry. The RefreshScope is a bean in the context and has a publicrefreshAll() method to refresh all beans in the scope by clearing the target cache.