Closed suqun closed 4 years ago
程序里有个这段代码,注释掉,就可以正常监听,不是注解和Nacos的问题。具体原因不是很了解,有懂的麻烦留个言,多谢
@Component
public class RedisTestService implements ApplicationRunner {
private static final Logger logger = Logger.getLogger(RedisTestService.class);
@Autowired
private RedisTemplate<String, String> redisTemplate;
@Override
public void run(ApplicationArguments args) throws Exception {
test();
}
public void test(){
int i = 0;
while (i==0){
redisTemplate.opsForValue().set("redis-test", "1");
try {
Thread.sleep(1000);
}catch (Exception e){}
}
}
}
Issue Description
Type: bug report
Describe what happened (or what feature you want)
ApplicationListener ApplicationReadyEvent not working,when use @ComponentScan.
springcloud启动类上使用@ComponentScan注解,导致NacosContextRefresher中的ApplicationReadyEvent事件监听失效
Describe what you expected to happen
NacosContextRefresher 监听失效会导致配置中心修改配置,无法刷新,期望可以刷新
How to reproduce it (as minimally and precisely as possible)
注释掉@ComponentScan ,启动测试,服务注册成功后打印监听日志,配置可以正常刷新
Tell us your environment
spring cloud version : Finchley.SR2 spring Cloud Alibaba Version : 2.0.2.RELEASE nacos version :1.2.1
Anything else we need to know?