I'm trying to reload the spring bean by using the actuator refresh endpoint with the help of @RefreshScope annotation at bean level in spring boot 2.2.7 version.
But my HelloWorld bean is not getting refreshed by hitting the refresh endpoint. Can anyone please help me out ?
My main class:
@SpringBootApplication
public class SampleApplication {
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
}
HelloWorld:
public class HelloWorld {
private String message;
public void setMessage(String message){
this.message = message;
}
public void getMessage(){
System.out.println("Your Message : " + message);
}
}
ApplicationConfiguration:
@Configuration
public class ApplicationConfiguration {
@Bean
@RefreshScope
public HelloWorld helloWorld() {
System.out.println("From HelloWorld");
return new HelloWorld();
}
}
application.properties:
management.endpoints.web.exposure.include=*