`
conkeyn
  • 浏览: 1524333 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
社区版块
存档分类
最新评论

dubbo java.lang.ClassCastException: java.lang.String cannot be cast to java.lan

阅读更多

dubbo java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Class

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxxxController': Injection of @DubboReference dependencies is failed; nested exception is java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Class
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:183) ~[spring-context-support-1.0.11.jar:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1425) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at com.echovin.demo.visit.VisitWebApplication.main(VisitWebApplication.java:12) [main/:?]
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Class
	at org.apache.dubbo.config.spring.util.DubboAnnotationUtils.resolveServiceInterfaceClass(DubboAnnotationUtils.java:95) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.util.DubboAnnotationUtils.resolveInterfaceName(DubboAnnotationUtils.java:78) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ServiceBeanNameBuilder.<init>(ServiceBeanNameBuilder.java:65) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ServiceBeanNameBuilder.create(ServiceBeanNameBuilder.java:78) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildReferencedBeanName(ReferenceAnnotationBeanPostProcessor.java:303) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildInjectedObjectCacheKey(ReferenceAnnotationBeanPostProcessor.java:292) ~[dubbo-2.7.8.jar:2.7.8]
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.getInjectedObject(AbstractAnnotationBeanPostProcessor.java:404) ~[spring-context-support-1.0.11.jar:?]
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor$AnnotatedFieldElement.inject(AbstractAnnotationBeanPostProcessor.java:626) ~[spring-context-support-1.0.11.jar:?]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:179) ~[spring-context-support-1.0.11.jar:?]
	... 18 more

参考: https://github.com/apache/dubbo/issues/7115

 

解决办法:

 

<dependency>
  <groupId>com.alibaba.cloud</groupId>
  <artifactId>spring-cloud-starter-dubbo</artifactId>
</dependency>
 <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
<dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>

 依赖的spring-context-support版本要对应,过高或过低版本,将导致上面的错误

 

<dependency>
   <groupId>com.alibaba.spring</groupId>
   <artifactId>spring-context-support</artifactId>
    <version>${alibaba_spring_context_support_version}</version>-->
</dependency>

 

分享到:
评论

相关推荐

    dubbo-2.8.4.jar

    at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.returnFromResponse(DefaultFuture.java:190) at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:110) at ...

    Invalid name=”com.alibaba.dubbo.config.ProtocolConfig#0″

    java.lang.IllegalStateException: Invalid name=“com.alibaba.dubbo.config.ProtocolConfig#0” contains illegal character, only digit, letter, ‘-’, ‘_’ or ‘.’ is legal 原因: 如果没有指定id属性,...

    dubbo-monitor-simple.zip

    dubbo-monitor监控中心,基于alibaba dubbo.jar开发,解决Decode rpc invocation failed: expected map/object at java.lang.String (Ljava/lang/String)、com.alibaba.dubbo.common.URL' could not be instantiated...

    dubbo2.8.4.jar

    如果使用dubbo遇到错误:com.alibaba.dubbo.remoting.RemotingException: Fail to decode request due to: RpcInvocation 请下载这个jar,替换掉你项目中的那个jar,应该可以解决。

    深入解析Dubbo内核.pdf

    深入解析Dubbo内核.pdf深入解析Dubbo内核.pdf深入解析Dubbo内核.pdf深入解析Dubbo内核.pdf深入解析Dubbo内核.pdf深入解析Dubbo内核.pdf深入解析Dubbo内核.pdf深入解析Dubbo内核.pdf深入解析Dubbo内核.pdf深入解析...

    dubbo找不到dubbo.xsd报错

    - schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root ...

    dubbo的.xsd文件分享

    本篇文章将深入探讨`dubbo.xsd`文件及其在Dubbo中的作用,旨在帮助读者理解Dubbo的服务治理机制。 首先,`dubbo.xsd`是Dubbo项目的核心配置文件之一,它定义了Dubbo服务的各种配置元素和属性。通过这个文件,开发者...

    品优购电商系统-springboot+dubbo版.zip

    -springboot+dubbo版.zip品优购电商系统--springboot+dubbo版.zip品优购电商系统--springboot+dubbo版.zip品优购电商系统--springboot+dubbo版.zip品优购电商系统--springboot+dubbo版.zip品优购电商系统--...

    dubbo 2.7.x 官方参考手册 用户文档

    Apache Dubbo是一个高性能的Java RPC框架,主要用于开发和管理分布式应用程序。用户文档通常包括了安装、配置、使用方法以及最佳实践等,帮助开发者能够快速上手并正确使用该框架。 描述中提到的“带目录,dubbo...

    Dubbo微服务架构下的Kubernetes云平台建设实践.docx

    ### Dubbo微服务架构下的Kubernetes云平台建设实践 #### 一、背景介绍 随着容器技术的迅猛发展,Kubernetes已成为容器编排领域的事实标准。Kubernetes的优势在于它能够实现自动化的部署、大规模的可扩展性和容器化...

    dubbo-admin.war.zip

    Dubbo,作为阿里巴巴开源的一款高性能、轻量级的Java RPC框架,为开发者提供了强大的服务治理功能。其中,`dubbo-admin`便是Dubbo生态中的一个重要组成部分,它是一个可视化的服务管理工具,可以帮助我们便捷地监控...

    dubbo2.5.3.jar

    dubbo2.5.3.jar dubbo2.5.3.jar dubbo2.5.3.jar dubbo2.5.3.jar dubbo2.5.3.jar

    解决dubbo启动的时候报错,无法读取方案文档 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd'

    解决启动dubbo项目的时候出现,无法读取方案文档 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd',其实在你本地把dubbo.jar文件解压,然后在META-INF下边就有个dubbo.xsd,就是他

    dubbo2.8.4.jar下载

    dubbo2.8.4.jar下载,不求赚分,只求一份爱心, dubbo2.8.4.jar下载 dubbo2.8.4.jar下载 dubbo2.8.4.jar下载 dubbo2.8.4.jar下载 dubbo2.8.4.jar下载

    java1.8 最新dubbo-admin.war

    《Java 1.8与Dubbo Admin:深入理解与应用》 在当今的软件开发领域,Java 1.8作为一款强大的编程语言,其稳定性和性能优化能力深受开发者喜爱。而Dubbo,作为阿里巴巴开源的一款高性能、轻量级的服务治理框架,更是...

    Dubbo管理控制台dubbo admin2.X for jdk8 (window,liunx)

    运行tomcat,然后访问tomcat根目录地址 (注意里面的WEB-INF/dubbo.properties中zookeeper的地址配置正确并且zookeeper服务正在运行) 默认用户 guest guest dubbo.registry.address=zookeeper://127.0.0.1:2181 ...

    基于java的开发源码-服务框架 Dubbo.zip

    基于java的开发源码-服务框架 Dubbo.zip 基于java的开发源码-服务框架 Dubbo.zip 基于java的开发源码-服务框架 Dubbo.zip 基于java的开发源码-服务框架 Dubbo.zip 基于java的开发源码-服务框架 Dubbo.zip 基于java的...

    dubbodubbo.zip

    在Java世界里,Dubbo已经成为了微服务架构的重要组成部分,其核心特性包括服务注册与发现、远程调用、负载均衡、容错与监控等。 一、Dubbo核心概念 1. **服务(Service)**:服务是Dubbo的基本单元,定义了服务的...

    Java的dubbo.xsd配置文件

    在Eclipse中配置Dubbo时,`dubbo.xsd`配置文件扮演着至关重要的角色。这个文件定义了Dubbo服务的所有配置元素和属性,遵循XML Schema(XSD)规范,确保XML配置文件的正确性和一致性。 `dubbo.xsd`文件包含了一系列...

Global site tag (gtag.js) - Google Analytics