Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nacos升到1.4.2之后,springboot使用@NacosPropertySource和@NacosValue自动刷新不能动态获取配置 #6257

Closed
zrlw opened this issue Jul 3, 2021 · 4 comments
Labels
status/invalid This doesn't seem right

Comments

@zrlw
Copy link
Contributor

zrlw commented Jul 3, 2021

Describe the bug
从1.2.1升到1.4.2之后,nacos配置中心更新配置时,springboot工程使用@NacosValue和@NacosPropertySource(autoRefreshed均设置为true)获取不到配置中心配置项的动态更新,只有自定义配置listener还能收到,之前两种方式都可以动态获取。
nacos-server 1.4.2
nacos-client 1.4.2
dubbo 2.7.12
nacos-config-spring-boot-starter 0.2.7
springboot 2.2.6

@zrlw zrlw changed the title nacos升到1.4.2之后,springboot使用@NacosProperties和@NacosValue自动刷新不能动态获取配置 nacos升到1.4.2之后,springboot使用@和@NacosValue自动刷新不能动态获取配置 Jul 3, 2021
@zrlw zrlw changed the title nacos升到1.4.2之后,springboot使用@和@NacosValue自动刷新不能动态获取配置 nacos升到1.4.2之后,springboot使用@NacosPropertySource和@NacosValue自动刷新不能动态获取配置 Jul 3, 2021
@zrlw
Copy link
Contributor Author

zrlw commented Jul 3, 2021

把nacos client版本退回到1.2.1就好了。
nacos client1.4.2删除了nacos-spring-context0.3.6(由nacos-config-spring-boot-starter 0.2.7引入)更新NacosValue数据时NacosValueAnnotationBeanPostProcessor要使用的com.alibaba.nacos.client.config.utils.MD5类(比较是否发生改变),动态更新数据前调用MD5比较是否发生变化时抛NoClassDefFoundError异常了,所以更新不了。
试着把nacos-config-spring-boot-starter升到0.2.8,结果出现@NacosInjected注入ConfigService到bean时抛异常,提示java.lang.ClassCastException:com.sun.proxy.$ProxyXXX cannot be cast to java.util.Map

@Component
public class xxx {
    @NacosInjected
    private ConfigService configService;

    @PostConstruct
     public void getNacosValue() {
          String nacosValue = configService.getConfig(dataId, groupId, ms);
          ...
    }
}

application.yml有配置nacos.config.server-addr和namespace。
注入@NacosInjected异常是另外一个issue: nacos-group/nacos-spring-boot-project#201

@realJackSun realJackSun added the area/Spring Boot Related to Spring Boot label Jul 5, 2021
@KomachiSion KomachiSion added status/invalid This doesn't seem right and removed area/Spring Boot Related to Spring Boot labels Jul 5, 2021
@KomachiSion
Copy link
Collaborator

Please upgrade to 0.2.8

@zrlw
Copy link
Contributor Author

zrlw commented Jul 5, 2021

升到0.2.8和dubbo冲突:
nacos-group/nacos-spring-boot-project#201
apache/dubbo#7797
根源是 alibaba的spring-context-support升到1.0.11并没有考虑向前兼容,AbstractAnnotationBeanPostProcessor新增的classValuesAsString,nestedAnnotationsAsMap默认为true,而当前所有dubbo版本的ReferenceAnnotationBeanPostProcessor依赖的是spring-context-support 1.0.10以及之前的版本,dubbo使用spring-context-support 1.0.11时需要将这两个值改为false。
我给dubbo提交了修订:
apache/dubbo#8217

@zrlw
Copy link
Contributor Author

zrlw commented Jul 7, 2021

@KomachiSion spring-context-support1.0.10不支持nacos1.4.2,spring-context-support 1.0.11不支持dubbo,两个社区不沟通一下么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants