@RefreshScope不使用@Configuration和@PropertySource

时间:2018-05-30 10:18:12

标签: spring spring-cloud spring-cloud-config

这是我的配置类

@Configuration
@RefreshScope
@PropertySource("classpath:application.properties")
public class MemcacheProperties {

    @Value("${watchdog.token}")
    private  String token ;

    @Bean
    public String getToken() {
        return token;
    }
}

这是我的班级消耗上面的课程

@Component
@RefreshScope
public class MemCacheService {

    @Autowired
    private MemcacheProperties properties;

   @Override
   public String get(String key) 
   {
              System.out.println("Property value:"+ properties.getToken());
   }
}

在application.properties中更改watchdog.token的值后,我解雇了

http://localhost:8080/v1/refresh

我收到了以下回复:

[
    "watchdog.token"
]

当调用MemcacheService的get方法时,仍会打印旧配置。这里出了什么问题?

PS:我的应用程序是一个Spring启动应用程序

0 个答案:

没有答案
相关问题