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-spring-context版本从0.3.6升至1.1.0之后,@NacosInjected注入bean时抛异常 #258
Comments
原因是dubbo和nacos-spring-context依赖的com.alibaba.spring/spring-context-support版本不同而且不兼容所致,需要排除dubbo的依赖版本,但是不知道这样做有没有其他副作用。 |
发现有副作用,排除掉dubbo依赖的spring-context-support版本之后,注入dubbo的@reference注解就会ClassCastException: java.lang.String cannot be cast to java.lang.Class ( DubboAnnotationUtils.java 95行) |
根源是 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。 |
我也有这个问题,真是头疼(后来把nacos-spring-context降级为0.3.6正常) |
Issue Description
Type: bug report
Describe what happened (or what feature you want)
程序里有@component组件使用了@NacosInjected注解,用nacos-spring-context 0.3.6版本时一切正常,升到1.1.0之后,启动抛ClassCastException,异常位置在AnnotationNacosInjectedBeanPostProcessor.java 145行,提示com.sun.proxy.$Proxy113 cannot be cast to java.util.Map,跟踪到此发现attributes对象是个map,key="properties"对应的value对象类型是@NacosProperties,转Map注定异常。
写了个测试工程,pom.xml有dubbo(测试了2.7.5、2.7.9、2.7.11三个版本)就会出现上述异常,去掉dubbo依赖就运行正常。
将nacos-spring-context版本降至0.3.6,也恢复正常。
Tell us your environment
spring-boot-starter-test 2.2.6.RELEASE
spring-boot-starter-log4j2 2.2.6.RELEASE
spring-boot-starter-aop 2.2.6.RELEASE
nacos client 1.4.2
dubbo 2.7.5 / 2.7.9 / 2.7.11
lombok 1.18.12
nacos-spring-context 1.1.0
The text was updated successfully, but these errors were encountered: