I'm having a problem when I trying refreshing scope of my application to get properties in a microservice using Spring Boot 3.0.6
Schenary
- I have a config-server running connected with my Github
- My Github contains a file with properties from my user-service-api
- When I call config server to get user-service-api properties (http://localhost:8888/user-service-api/dev) I have this response
{
"name": "user-service-api",
"profiles": [
"dev"
],
"label": null,
"version": "90baae4177b982a490fe7400f8659952bceaddfa",
"state": null,
"propertySources": [
{
"name": "https://github.com/ValdirCezar/formacao-backend-expert-configs/user-service-api-dev.yml",
"source": {
"spring.application.name": "user-service-api",
"spring.data.mongodb.auto-index-creation": true,
"springdoc.openapi.title": "User Service API TEST",
"springdoc.openapi.version": "1.0.0",
"server.port": "${SERVER_PORT:8080}"
}
}
]
}
When I change properties in my github
spring:
application:
name: 'user-service-api'
data:
springdoc:
openapi:
title: 'User Service API'
version: '1.0.0'
server:
port: ${SERVER_PORT:8080}
The config server response is updated
In my user-service-api
application.yml
spring:
application:
name: 'user-service-api'
cloud:
config:
uri: ${CONFIG_SERVER_URI:http://localhost:8888}
bootstrap.yml
management:
endpoints:
web:
exposure:
include: '*'
I added the @RefresScope on my OpenAPI Config class
@RefreshScope
@Configuration
public class OpenAPIConfig {
@Bean
public OpenAPI customOpenAPI(
@Value("${springdoc.openapi.title}") final String title,
@Value("${springdoc.openapi.description}") final String description,
@Value("${springdoc.openapi.version}") final String version
) {
return new OpenAPI()
.info(new Info()
.title(title)
.description(description)
.version(version)
);
}
}
dependencies
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.8'
id 'io.spring.dependency-management' version '1.1.0'
}
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
When I reload the application, this configs update, but when I call http://localhost:8888/actuator/refresh to refresh scope not working
With spring boot 2.0.6 works but not with 3.0.6