I have Spring config server and able configured the git property and my spring client application is reading the the property from git but If I change the property in git then my spring client app is not able to pick the changed property.If I restart the client application than my client application is able to read the changed property value from git. Requirement-I don't want to restart the client application,Without restarting the client application,My client application should read the changed property.I have tried with the @RefreshScope. but no success
Below are my spring client sample app-
@Configuration
@EnableAutoConfiguration
@ComponentScan({"com.abc.xyz"})
@RefreshScope
public class MyClientApplication {
}
Config Server Annotation
@EnableConfigServer
@SpringBootApplication
public class MyConfigServer{
}
Can you Please help me on this
Comment From: spencergibb
What happened when you called /refresh on the client application?
Comment From: AvnishOmi
@spencergibb When I call /refresh on client app, then following log file-
2016-10-03 22:02:54.052 INFO 15716 --- [nio-6061-exec-3] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@5f7ce95f: startup date [Mon Oct 03 22:02:54 MDT 2016]; root of context hierarchy
2016-10-03 22:02:54.071 INFO 15716 --- [nio-6061-exec-3] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-10-03 22:02:54.072 INFO 15716 --- [nio-6061-exec-3] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$2046f8e3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-10-03 22:02:54.787 INFO 15716 --- [nio-6061-exec-3] o.s.boot.SpringApplication : The following profiles are active: qa
2016-10-03 22:02:54.788 INFO 15716 --- [nio-6061-exec-3] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4436b469: startup date [Mon Oct 03 22:02:54 MDT 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5f7ce95f
2016-10-03 22:02:54.789 INFO 15716 --- [nio-6061-exec-3] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-10-03 22:02:54.795 INFO 15716 --- [nio-6061-exec-3] o.s.boot.SpringApplication : Started application in 1.417 seconds (JVM running for 247.712)
2016-10-03 22:02:54.795 INFO 15716 --- [nio-6061-exec-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@4436b469: startup date [Mon Oct 03 22:02:54 MDT 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5f7ce95f
2016-10-03 22:02:54.795 INFO 15716 --- [nio-6061-exec-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@5f7ce95f: startup date [Mon Oct 03 22:02:54 MDT 2016]; root of context hierarchy
Comment From: spencergibb
I'm unable to determine what is happening based on what you have provided. Do you have a project, including git repo, that reproduces the problem?
Comment From: AvnishOmi
@spencergibb-Thanks for the comment-I have resolved this issue.I provided the @RefreshScope annotation for every bean including of my main boot application MyClientApplication.java.But I have one quick question-Can i customize and implement in the code so that i dont need to call /refresh endpoint.When property change in git repo my client application automatically detect the changes and fetch the updated property
Comment From: spencergibb
@RefreshScope shouldn't be needed if you are using @ConfigurationProperties. If you are putting it on every bean, something is wrong. See /monitor docs for push notifications.
Comment From: AvnishOmi
@spencergibb Yes i am using @ConfigurationProperties like below @Service @ConfigurationProperties(prefix = "account.service") @RefreshScope public class AccountService{ } You mean if if i will use @ConfigurationProperties then @RefreshScope is not needed.If @RefreshScope is not required in this case then how properties will be refreshed?
Comment From: spencergibb
That is the feature, that it doesn't need refresh scope
Comment From: isarwarfp
I am also facing the same issue.
Here are my repositories
Configuration Files
https://github.com/imranbutt-java/scf-config-repository-1.git
Config Server
https://github.com/imranbutt-java/config-server.git
Config Client App
https://github.com/imranbutt-java/config-client-app.git
Discover Server
https://github.com/imranbutt-java/practice.git
Comment From: javaHelper
https://stackoverflow.com/questions/66922674/unable-to-fetch-property-value-from-the-config-server. - Here is the issue too