前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >dubbo入门学习

dubbo入门学习

作者头像
别先生
发布2019-08-06 16:49:58
8700
发布2019-08-06 16:49:58
举报
文章被收录于专栏:别先生别先生

官方网址:http://dubbo.apache.org/zh-cn/index.html

学习可以参考官网中文文档:http://dubbo.apache.org/zh-cn/docs/user/quick-start.html

1、Apache Dubbo是一款高性能、轻量级的开源Java RPC框架,它提供了三大核心能力:面向接口的远程方法调用,智能容错和负载均衡,以及服务自动注册和发现。

代码语言:javascript
复制
1 如果项目表现层、服务层是不同的项目,可以使用dubbo实现两个系统之间的通信。服务层和表现层相互通信,使用dubbo中间件,让表现层调用服务层。工程之间的相互通信可以使用dubbo,,可以统一管理服务,系统之间的调用。
2 如何实现远程通信。
3   1、Webservice,效率不高,基于soap协议,项目中不推荐使用。
4   2、使用restful形式的服务,http+json,很多项目中应用。如果服务太多,服务之间的调用关系混乱,需要治疗服务。
5   3、dubbo,使用rpc协议进行远程调用,直接使用socket通信,传输效率高,并且可以统计出系统之间的调用关系,调用次数。缺点,由于是java开发,只能是两个java项目进行调度。

2、dubbo架构。术语来自官网。可以直接查看官网。

节点角色说明

节点

角色说明

Provider

暴露服务的服务提供方

Consumer

调用远程服务的服务消费方

Registry

服务注册与发现的注册中心

Monitor

统计服务的调用次数和调用时间的监控中心

Container

服务运行容器

调用关系说明
  1. 服务容器负责启动,加载,运行服务提供者。
  2. 服务提供者在启动时,向注册中心注册自己提供的服务。
  3. 服务消费者在启动时,向注册中心订阅自己所需的服务。
  4. 注册中心返回服务提供者地址列表给消费者,如果有变更,注册中心将基于长连接推送变更数据给消费者。
  5. 服务消费者,从提供者地址列表中,基于软负载均衡算法,选一台提供者进行调用,如果调用失败,再选另一台调用。
  6. 服务消费者和提供者,在内存中累计调用次数和调用时间,定时每分钟发送一次统计数据到监控中心。

Dubbo 架构具有以下几个特点,分别是连通性、健壮性、伸缩性、以及向未来架构的升级性。

3、注册中心(推荐zookeeper,也可以使用redis的呢)   注册中心负责服务地址得注册与查找,相当于目录服务,服务提供者和消费者只在启动得时候与注册中心交互,注册中心不转发请求,压力较小,使用dubbo2.3.3以上版本,建议使用zookeeper注册中心。zookeeper是一个树形的目录服务,支持变更推送,适合作为dubbo服务的注册中心,工业强度高,可以用于生产环境,推荐使用。

4、安装zookeeper,必须首先安装jdk,这里安装jdk1.7版本。首先将安装包上传到机器上面哦。

[root@localhost jdk1.7.0_55]# tar -zxvf jdk-7u55-linux-i586.tar.gz -C /home/hadoop/soft

[root@localhost ~]# vim /etc/profile

代码语言:javascript
复制
1 export JAVA_HOME=/home/hadoop/soft/jdk1.7.0_55
2 export PATH=$PATH:$JAVA_HOME/bin

[root@localhost ~]# source /etc/profile

[root@localhost ~]# java

[root@localhost ~]# javac

[root@localhost ~]# java -version

5、开始安装zookeeper,首先将安装包上传到机器上面哦。

解压缩操作哦。

[root@localhost package]# tar -zxvf zookeeper-3.4.6.tar.gz -C /home/hadoop/soft/

然后配置一下zookeeper,就可以启动zookeeper了。

首先创建一个data文件夹。

配置完成了,就可以启动zookeeper。进行验证是否可以正常启动。

代码语言:javascript
复制
1 [root@localhost bin]# ./zkServer.sh start
2 JMX enabled by default
3 Using config: /home/hadoop/soft/zookeeper-3.4.6/bin/../conf/zoo.cfg
4 Starting zookeeper ... STARTED
5 [root@localhost bin]# ./zkServer.sh status
6 JMX enabled by default
7 Using config: /home/hadoop/soft/zookeeper-3.4.6/bin/../conf/zoo.cfg
8 Mode: standalone
9 [root@localhost bin]#

[root@localhost bin]# ./zkServer.sh start 启动 [root@localhost bin]# ./zkServer.sh status 查看启动状态 [root@localhost bin]# ./zkServer.sh stop 关闭

6、zookeeper安装成功以后,就可以操作,服务如何发布,客户端如何引用服务。

Dubbo采用全Spring配置方式,透明化接入应用,对应用没有任何api侵入,只需要用spring加载dubbo的配置即可,dubbo基于spring的schema扩展进行加载。 远程服务。在本地服务的基础上,只需要简单的配置,即可以完成远程话。 将传统写的xml配置文件中的bean注入以及bean的依赖注入的配置拆分成两份,将服务定义部分放在服务提供方remote-provider.xml,将服务引用部分放在服务消费方remote-consumer.xml配置文件中。并在提供方增加暴漏服务配置<dubbo:service>,在消费方增加引用服务配置<dubbo:reference>。官网截图:

7、发布dubbo服务。定义一个接口。

代码语言:javascript
复制
 1 package com.taotao.service;
 2 
 3 import com.taotao.pojo.TbItem;
 4 
 5 /**
 6  * 
 7  * @ClassName: ItemService.java
 8  * @author: biehl
 9  * @since: 2019年8月2日 下午3:32:36
10  * @Copyright: ©2019 biehl 版权所有
11  * @version: 0.0.1
12  * @Description:商品接口类
13  * 
14  */
15 public interface ItemService {
16 
17     /**
18      * 根据itemId查询出商品信息
19      * 
20      * @param itemId
21      * @return
22      */
23     public TbItem getItemById(long itemId);
24     
25 }

定义实现接口的实现类。

代码语言:javascript
复制
 1 package com.taotao.service.impl;
 2 
 3 import org.springframework.beans.factory.annotation.Autowired;
 4 import org.springframework.stereotype.Service;
 5 import org.springframework.util.StringUtils;
 6 
 7 import com.taotao.mapper.TbItemMapper;
 8 import com.taotao.pojo.TbItem;
 9 import com.taotao.service.ItemService;
10 
11 /**
12  * 
13  * @ClassName: ItemServiceImpl.java
14  * @author: biehl
15  * @since: 2019年8月2日 下午3:51:24
16  * @Copyright: ©2019 biehl 版权所有
17  * @version: 0.0.1
18  * @Description: 商品实现类
19  */
20 @Service
21 public class ItemServiceImpl implements ItemService {
22 
23     @Autowired
24     private TbItemMapper tbItemMapper;
25 
26     @Override
27     public TbItem getItemById(long itemId) {
28         TbItem tbItem = new TbItem();
29         if (!StringUtils.isEmpty(itemId)) {
30             tbItem = tbItemMapper.selectByPrimaryKey(itemId);
31         }
32         // 返回信息以后就可以发布服务
33         return tbItem;
34     }
35 
36 }

配置提供dubbo的服务。

代码语言:javascript
复制
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:context="http://www.springframework.org/schema/context"
 4     xmlns:p="http://www.springframework.org/schema/p"
 5     xmlns:aop="http://www.springframework.org/schema/aop"
 6     xmlns:tx="http://www.springframework.org/schema/tx"
 7     xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
 8     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 9     xsi:schemaLocation="http://www.springframework.org/schema/beans 
10     http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
11     http://www.springframework.org/schema/context 
12     http://www.springframework.org/schema/context/spring-context-4.2.xsd
13     http://www.springframework.org/schema/aop 
14     http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
15     http://www.springframework.org/schema/tx 
16     http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
17     http://code.alibabatech.com/schema/dubbo 
18     http://code.alibabatech.com/schema/dubbo/dubbo.xsd
19     http://www.springframework.org/schema/util 
20     http://www.springframework.org/schema/util/spring-util-4.2.xsd">
21 
22     <!-- 1、配置包扫描器,扫描所有带@Service注解的类,將創建的對象放到Spring容器中 -->
23     <!-- 也可以将子包扫描进去 -->
24     <!-- 将扫描com.taotao.service、com.taotao.service.impl -->
25     <context:component-scan
26         base-package="com.taotao.service"></context:component-scan>
27 
28     <!-- 配置spring的事务,单独提取出来 -->
29 
30     <!-- 发布dubbo服务 -->
31     <!-- 提供方应用信息,用于计算依赖关系 -->
32     <dubbo:application name="taotao-manager" />
33     <!-- 注册中心的地址 -->
34     <dubbo:registry protocol="zookeeper" address="192.168.110.140:2181" />
35     <!-- 用dubbo协议在20880端口暴露服务 -->
36     <dubbo:protocol name="dubbo" port="20880" />
37     <!-- 声明需要暴露的服务接口 -->
38     <!-- ref="itemServiceImpl"就是扫描service的时候,注入到容器的bean -->
39     <dubbo:service interface="com.taotao.service.ItemService" ref="itemServiceImpl" timeout="300000" />
40     <!-- <dubbo:service interface="com.taotao.service.ItemCatService" ref="itemCatServiceImpl" timeout="300000" /> -->
41 
42     
43     
44     
45     
46 
47 </beans>    

如图所示:

8、在表现层引用dubbo的服务。提供方和引用方都需要引入dubbo的jar包哦。

代码语言:javascript
复制
 1 <!-- dubbo相关 -->
 2 <dependency>
 3     <groupId>com.alibaba</groupId>
 4     <artifactId>dubbo</artifactId>
 5     <!-- 排除spring的2.5.6版本,netty3.2.5版本,避免冲突 -->
 6     <exclusions>
 7         <exclusion>
 8             <groupId>org.springframework</groupId>
 9             <artifactId>spring</artifactId>
10         </exclusion>
11         <exclusion>
12             <groupId>org.jboss.netty</groupId>
13             <artifactId>netty</artifactId>
14         </exclusion>
15     </exclusions>
16 </dependency>
17 <dependency>
18     <groupId>org.apache.zookeeper</groupId>
19     <artifactId>zookeeper</artifactId>
20 </dependency>
21 <dependency>
22     <groupId>com.github.sgroschupf</groupId>
23     <artifactId>zkclient</artifactId>
24 </dependency>

配置一下引用方的配置。

代码语言:javascript
复制
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 4     xmlns:p="http://www.springframework.org/schema/p"
 5     xmlns:context="http://www.springframework.org/schema/context"
 6     xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
 7     xmlns:mvc="http://www.springframework.org/schema/mvc"
 8     xsi:schemaLocation="http://www.springframework.org/schema/beans 
 9         http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
10         http://www.springframework.org/schema/mvc 
11         http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
12         http://code.alibabatech.com/schema/dubbo 
13         http://code.alibabatech.com/schema/dubbo/dubbo.xsd
14         http://www.springframework.org/schema/context 
15         http://www.springframework.org/schema/context/spring-context-4.2.xsd">
16 
17     <!-- 1、加载属性文件 -->
18     <!-- <context:property-placeholder location="classpath:resource/resource.properties"/> -->
19     
20     <!-- 2、配置注解驱动 -->
21     <mvc:annotation-driven />
22     
23     <!-- 3、视图解析器 -->
24     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
25         <property name="prefix" value="/WEB-INF/jsp/" />
26         <property name="suffix" value=".jsp" />
27     </bean>
28     
29     <!-- 4、配置包扫描器,扫描@Controller注解的类 -->
30     <context:component-scan base-package="com.taotao.controller"/>
31     
32     <!-- 5、配置资源映射 -->
33     <mvc:resources location="/css/" mapping="/css/**"/>
34     <mvc:resources location="/js/" mapping="/js/**"/>
35     
36     <!-- 6、多媒体解析器 -->
37     <!-- 配置文件上传解析器 -->
38     <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
39         <!-- 设定默认编码 -->
40         <property name="defaultEncoding" value="UTF-8"></property>
41         <!-- 设定文件上传的最大值5MB,5*1024*1024 -->
42         <property name="maxUploadSize" value="5242880"></property>
43     </bean>
44     
45     
46     <!-- 引用服务,也要在spring容器中,直接在这里引用即可 -->
47     <!-- 引用dubbo服务 -->
48     <!-- 名称不一样的哦 -->
49     <dubbo:application name="taotao-manager-web"/>
50     <dubbo:registry protocol="zookeeper" address="192.168.110.140:2181"/>    
51     <dubbo:reference interface="com.taotao.service.ItemService" id="itemService" />
52     <!-- <dubbo:reference interface="com.taotao.service.ItemCatService" id="itemCatService" />
53     <dubbo:reference interface="com.taotao.content.service.ContentCategoryService" id="contentCategoryService" />
54     <dubbo:reference interface="com.taotao.content.service.ContentService" id="contentService" />
55     <dubbo:reference interface="com.taotao.search.service.SearchItemService" id="searchItemService" /> -->
56     
57     
58     
59     
60 </beans>      
代码语言:javascript
复制
 1 package com.taotao.controller;
 2 
 3 import org.springframework.beans.factory.annotation.Autowired;
 4 import org.springframework.stereotype.Controller;
 5 import org.springframework.web.bind.annotation.PathVariable;
 6 import org.springframework.web.bind.annotation.RequestMapping;
 7 import org.springframework.web.bind.annotation.ResponseBody;
 8 
 9 import com.taotao.pojo.TbItem;
10 import com.taotao.service.ItemService;
11 
12 /**
13  * 
14  * @ClassName: ItemController.java
15  * @author: biehl
16  * @since: 2019年8月2日 下午5:10:31
17  * @Copyright: ©2019 biehl 版权所有
18  * @version: 0.0.1
19  * @Description:商品信息的控制层逻辑
20  */
21 @Controller
22 public class ItemController {
23 
24     // itemService就是dubbo配置的id="itemService"
25     @Autowired
26     private ItemService itemService;
27 
28     @RequestMapping(value = "/item/{itemId}")
29     @ResponseBody
30     public TbItem getItemById(@PathVariable(value = "itemId") Long itemId) {
31         TbItem tbItem = new TbItem();
32         tbItem = itemService.getItemById(itemId);    
33         return tbItem;
34     }
35 
36 }

9、dubbo服务调用测试。记得关闭dubbo服务器的防火墙,不然急死你。

访问http://localhost:8081/item/536563,报错了,然后呢,解决问题呗。是因为mapper映射文件没有发布的问题。在工程的pom配置文件里面添加如下配置内容。

代码语言:javascript
复制
  1 [INFO] Scanning for projects...
  2 [INFO] 
  3 [INFO] -------------------< com.taotao:taotao-manager-web >--------------------
  4 [INFO] Building taotao-manager-web 0.0.1-SNAPSHOT
  5 [INFO] --------------------------------[ war ]---------------------------------
  6 [INFO] 
  7 [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ taotao-manager-web ---
  8 [INFO] Deleting D:\program\eclipse\eclipse\workspace_taotao\taotao-manager-web\target
  9 [INFO] 
 10 [INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) > process-classes @ taotao-manager-web >>>
 11 [INFO] 
 12 [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ taotao-manager-web ---
 13 [INFO] Using 'UTF-8' encoding to copy filtered resources.
 14 [INFO] Copying 1 resource
 15 [INFO] 
 16 [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ taotao-manager-web ---
 17 [INFO] Changes detected - recompiling the module!
 18 [INFO] Compiling 1 source file to D:\program\eclipse\eclipse\workspace_taotao\taotao-manager-web\target\classes
 19 [INFO] 
 20 [INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) < process-classes @ taotao-manager-web <<<
 21 [INFO] 
 22 [INFO] 
 23 [INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ taotao-manager-web ---
 24 [INFO] Running war on http://localhost:8081/
 25 [INFO] Creating Tomcat server configuration at D:\program\eclipse\eclipse\workspace_taotao\taotao-manager-web\target\tomcat
 26 [INFO] create webapp with contextPath: 
 27 八月 03, 2019 10:24:41 下午 org.apache.coyote.AbstractProtocol init
 28 信息: Initializing ProtocolHandler ["http-bio-8081"]
 29 八月 03, 2019 10:24:41 下午 org.apache.catalina.core.StandardService startInternal
 30 信息: Starting service Tomcat
 31 八月 03, 2019 10:24:41 下午 org.apache.catalina.core.StandardEngine startInternal
 32 信息: Starting Servlet Engine: Apache Tomcat/7.0.47
 33 八月 03, 2019 10:24:44 下午 org.apache.catalina.core.ApplicationContext log
 34 信息: No Spring WebApplicationInitializer types detected on classpath
 35 log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
 36 log4j:WARN Please initialize the log4j system properly.
 37 log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
 38 八月 03, 2019 10:24:44 下午 org.apache.catalina.core.ApplicationContext log
 39 信息: Initializing Spring FrameworkServlet 'taotao-manager-web'
 40 八月 03, 2019 10:24:46 下午 org.apache.coyote.AbstractProtocol start
 41 信息: Starting ProtocolHandler ["http-bio-8081"]
 42 八月 03, 2019 10:27:16 下午 org.apache.catalina.core.StandardWrapperValve invoke
 43 严重: Servlet.service() for servlet [taotao-manager-web] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.taotao.mapper.TbItemMapper.selectByPrimaryKey
 44 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.taotao.mapper.TbItemMapper.selectByPrimaryKey
 45     at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
 46     at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
 47     at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
 48     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
 49     at com.sun.proxy.$Proxy32.selectByPrimaryKey(Unknown Source)
 50     at com.taotao.service.impl.ItemServiceImpl.getItemById(ItemServiceImpl.java:23)
 51     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 52     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 53     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 54     at java.lang.reflect.Method.invoke(Method.java:606)
 55     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
 56     at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
 57     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
 58     at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
 59     at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
 60     at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
 61     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
 62     at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
 63     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
 64     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
 65     at com.sun.proxy.$Proxy35.getItemById(Unknown Source)
 66     at com.alibaba.dubbo.common.bytecode.Wrapper0.invokeMethod(Wrapper0.java)
 67     at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46)
 68     at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72)
 69     at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
 70     at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64)
 71     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 72     at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
 73     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 74     at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
 75     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 76     at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
 77     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 78     at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60)
 79     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 80     at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112)
 81     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 82     at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
 83     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 84     at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
 85     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 86     at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108)
 87     at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
 88     at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
 89     at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
 90     at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
 91     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 92     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 93     at java.lang.Thread.run(Thread.java:745)
 94 ] with root cause
 95 java.lang.RuntimeException: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.taotao.mapper.TbItemMapper.selectByPrimaryKey
 96 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.taotao.mapper.TbItemMapper.selectByPrimaryKey
 97     at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
 98     at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
 99     at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
100     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
101     at com.sun.proxy.$Proxy32.selectByPrimaryKey(Unknown Source)
102     at com.taotao.service.impl.ItemServiceImpl.getItemById(ItemServiceImpl.java:23)
103     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
104     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
105     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
106     at java.lang.reflect.Method.invoke(Method.java:606)
107     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
108     at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
109     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
110     at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
111     at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
112     at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
113     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
114     at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
115     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
116     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
117     at com.sun.proxy.$Proxy35.getItemById(Unknown Source)
118     at com.alibaba.dubbo.common.bytecode.Wrapper0.invokeMethod(Wrapper0.java)
119     at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46)
120     at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72)
121     at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
122     at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64)
123     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
124     at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
125     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
126     at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
127     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
128     at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
129     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
130     at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60)
131     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
132     at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112)
133     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
134     at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
135     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
136     at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
137     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
138     at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108)
139     at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
140     at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
141     at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
142     at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
143     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
144     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
145     at java.lang.Thread.run(Thread.java:745)
146 
147     at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:108)
148     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
149     at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
150     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
151     at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
152     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
153     at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
154     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
155     at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60)
156     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
157     at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112)
158     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
159     at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
160     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
161     at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
162     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
163     at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108)
164     at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
165     at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
166     at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
167     at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
168     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
169     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
170     at java.lang.Thread.run(Thread.java:745)

为解决问题的时候,只有接口,没有对应的配置SQL文件。

在pom配置文件里面添加如下配置即可。默认是将src/main/resources目录下面的文件放到\target\classes\目标目录下面,现在修改默认配置,将src/main/java目录下面的文件放到\target\classes\目标目录下面。

代码语言:javascript
复制
 1 <!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉的。 -->
 2 <build>
 3     <resources>
 4         <resource>
 5             <directory>src/main/java</directory>
 6             <includes>
 7                 <include>**/*.xml</include>
 8             </includes>
 9         </resource>
10         <!-- <resource> 如果需要复制resources下面的文件,需要添加此配置即可
11             <directory>src/main/resources</directory>
12             <includes>
13                 <include>**/*.xml</include>
14             </includes>
15         </resource> -->
16     </resources>
17 </build>

然后重启dubbo的发布服务。dubbo的应用服务可以不用重启,表现层只需要调用服务即可。然后又报了下面这个错误。聚合工程下面的模块修改了,也不需要安装,因为你启动的是聚合工程,所以直接启动聚合工程即可。

代码语言:javascript
复制
  1 [INFO] Scanning for projects...
  2 [INFO] 
  3 [INFO] -------------------< com.taotao:taotao-manager-web >--------------------
  4 [INFO] Building taotao-manager-web 0.0.1-SNAPSHOT
  5 [INFO] --------------------------------[ war ]---------------------------------
  6 [INFO] 
  7 [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ taotao-manager-web ---
  8 [INFO] Deleting D:\program\eclipse\eclipse\workspace_taotao\taotao-manager-web\target
  9 [INFO] 
 10 [INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) > process-classes @ taotao-manager-web >>>
 11 [INFO] 
 12 [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ taotao-manager-web ---
 13 [INFO] Using 'UTF-8' encoding to copy filtered resources.
 14 [INFO] Copying 1 resource
 15 [INFO] 
 16 [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ taotao-manager-web ---
 17 [INFO] Changes detected - recompiling the module!
 18 [INFO] Compiling 1 source file to D:\program\eclipse\eclipse\workspace_taotao\taotao-manager-web\target\classes
 19 [INFO] 
 20 [INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) < process-classes @ taotao-manager-web <<<
 21 [INFO] 
 22 [INFO] 
 23 [INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ taotao-manager-web ---
 24 [INFO] Running war on http://localhost:8081/
 25 [INFO] Creating Tomcat server configuration at D:\program\eclipse\eclipse\workspace_taotao\taotao-manager-web\target\tomcat
 26 [INFO] create webapp with contextPath: 
 27 八月 03, 2019 10:35:40 下午 org.apache.coyote.AbstractProtocol init
 28 信息: Initializing ProtocolHandler ["http-bio-8081"]
 29 八月 03, 2019 10:35:40 下午 org.apache.catalina.core.StandardService startInternal
 30 信息: Starting service Tomcat
 31 八月 03, 2019 10:35:40 下午 org.apache.catalina.core.StandardEngine startInternal
 32 信息: Starting Servlet Engine: Apache Tomcat/7.0.47
 33 八月 03, 2019 10:35:43 下午 org.apache.catalina.core.ApplicationContext log
 34 信息: No Spring WebApplicationInitializer types detected on classpath
 35 log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
 36 log4j:WARN Please initialize the log4j system properly.
 37 log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
 38 八月 03, 2019 10:35:43 下午 org.apache.catalina.core.ApplicationContext log
 39 信息: Initializing Spring FrameworkServlet 'taotao-manager-web'
 40 八月 03, 2019 10:35:45 下午 org.apache.coyote.AbstractProtocol start
 41 信息: Starting ProtocolHandler ["http-bio-8081"]
 42 八月 03, 2019 10:36:10 下午 org.apache.catalina.core.StandardWrapperValve invoke
 43 严重: Servlet.service() for servlet [taotao-manager-web] in context with path [] threw exception [Request processing failed; nested exception is com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method getItemById in the service com.taotao.service.ItemService. Tried 3 times of the providers [192.168.110.1:20880] (1/1) from the registry 192.168.110.140:2181 on the consumer 192.168.110.1 using the dubbo version 2.5.3. Last error is: Failed to invoke remote method: getItemById, provider: dubbo://192.168.110.1:20880/com.taotao.service.ItemService?anyhost=true&application=taotao-manager-web&check=false&dubbo=2.5.3&interface=com.taotao.service.ItemService&methods=getItemById&pid=10872&revision=0.0.1-SNAPSHOT&side=consumer&timeout=300000&timestamp=1564842944801, cause: Failed to send response: Response [id=2, version=2.0.0, status=20, event=false, error=null, result=RpcResult [result=com.taotao.pojo.TbItem@2e3ba04a, exception=null]], cause: java.lang.IllegalStateException: Serialized class com.taotao.pojo.TbItem must implement java.io.Serializable
 44 java.lang.IllegalStateException: Serialized class com.taotao.pojo.TbItem must implement java.io.Serializable
 45     at com.alibaba.com.caucho.hessian.io.SerializerFactory.getDefaultSerializer(SerializerFactory.java:261)
 46     at com.alibaba.com.caucho.hessian.io.SerializerFactory.getSerializer(SerializerFactory.java:233)
 47     at com.alibaba.com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:406)
 48     at com.alibaba.dubbo.common.serialize.support.hessian.Hessian2ObjectOutput.writeObject(Hessian2ObjectOutput.java:92)
 49     at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCodec.encodeResponseData(DubboCodec.java:200)
 50     at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.encodeResponse(ExchangeCodec.java:276)
 51     at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:77)
 52     at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:39)
 53     at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:81)
 54     at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.doEncode(OneToOneEncoder.java:66)
 55     at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:59)
 56     at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
 57     at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:784)
 58     at org.jboss.netty.channel.SimpleChannelHandler.writeRequested(SimpleChannelHandler.java:292)
 59     at com.alibaba.dubbo.remoting.transport.netty.NettyHandler.writeRequested(NettyHandler.java:99)
 60     at org.jboss.netty.channel.SimpleChannelHandler.handleDownstream(SimpleChannelHandler.java:254)
 61     at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
 62     at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:582)
 63     at org.jboss.netty.channel.Channels.write(Channels.java:704)
 64     at org.jboss.netty.channel.Channels.write(Channels.java:671)
 65     at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:248)
 66     at com.alibaba.dubbo.remoting.transport.netty.NettyChannel.send(NettyChannel.java:98)
 67     at com.alibaba.dubbo.remoting.transport.AbstractPeer.send(AbstractPeer.java:51)
 68     at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:171)
 69     at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
 70     at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
 71     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 72     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 73     at java.lang.Thread.run(Thread.java:745)
 74 ] with root cause
 75 com.alibaba.dubbo.remoting.RemotingException: Failed to send response: Response [id=2, version=2.0.0, status=20, event=false, error=null, result=RpcResult [result=com.taotao.pojo.TbItem@2e3ba04a, exception=null]], cause: java.lang.IllegalStateException: Serialized class com.taotao.pojo.TbItem must implement java.io.Serializable
 76 java.lang.IllegalStateException: Serialized class com.taotao.pojo.TbItem must implement java.io.Serializable
 77     at com.alibaba.com.caucho.hessian.io.SerializerFactory.getDefaultSerializer(SerializerFactory.java:261)
 78     at com.alibaba.com.caucho.hessian.io.SerializerFactory.getSerializer(SerializerFactory.java:233)
 79     at com.alibaba.com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:406)
 80     at com.alibaba.dubbo.common.serialize.support.hessian.Hessian2ObjectOutput.writeObject(Hessian2ObjectOutput.java:92)
 81     at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCodec.encodeResponseData(DubboCodec.java:200)
 82     at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.encodeResponse(ExchangeCodec.java:276)
 83     at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:77)
 84     at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:39)
 85     at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:81)
 86     at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.doEncode(OneToOneEncoder.java:66)
 87     at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:59)
 88     at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
 89     at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:784)
 90     at org.jboss.netty.channel.SimpleChannelHandler.writeRequested(SimpleChannelHandler.java:292)
 91     at com.alibaba.dubbo.remoting.transport.netty.NettyHandler.writeRequested(NettyHandler.java:99)
 92     at org.jboss.netty.channel.SimpleChannelHandler.handleDownstream(SimpleChannelHandler.java:254)
 93     at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
 94     at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:582)
 95     at org.jboss.netty.channel.Channels.write(Channels.java:704)
 96     at org.jboss.netty.channel.Channels.write(Channels.java:671)
 97     at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:248)
 98     at com.alibaba.dubbo.remoting.transport.netty.NettyChannel.send(NettyChannel.java:98)
 99     at com.alibaba.dubbo.remoting.transport.AbstractPeer.send(AbstractPeer.java:51)
100     at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:171)
101     at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
102     at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
103     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
104     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
105     at java.lang.Thread.run(Thread.java:745)
106 
107     at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.returnFromResponse(DefaultFuture.java:190)
108     at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:110)
109     at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:84)
110     at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:96)
111     at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:144)
112     at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:74)
113     at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53)
114     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
115     at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
116     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
117     at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:48)
118     at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
119     at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
120     at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:77)
121     at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227)
122     at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72)
123     at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
124     at com.alibaba.dubbo.common.bytecode.proxy0.getItemById(proxy0.java)
125     at com.taotao.controller.ItemController.getItemById(ItemController.java:28)
126     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
127     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
128     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
129     at java.lang.reflect.Method.invoke(Method.java:606)
130     at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
131     at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
132     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
133     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
134     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
135     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
136     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
137     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
138     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
139     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
140     at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
141     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
142     at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
143     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
144     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
145     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
146     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
147     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
148     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
149     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
150     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
151     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
152     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
153     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
154     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
155     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
156     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
157     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
158     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
159     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
160     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
161     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
162     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
163     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
164     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
165     at java.lang.Thread.run(Thread.java:745)

报这种序列号的错误,是实体类必须实现序列化接口,将查询出的数据必须进行序列化,才可以进行传输。将服务层的序列化的数据传递给表现层(客户端),然后表现层进行反序列化即可。里面的实体类,除了example的都实现序列化即可。

由于表现层在表现层可能会用到,所以将pojo安装一下。就可以了。

最后重启dubbo的提供服务,然后重启dubbo的引用服务。终于出现数据了。

10、dubbo的监控中心。

待续......

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-08-02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 节点角色说明
  • 调用关系说明
相关产品与服务
文件存储
文件存储(Cloud File Storage,CFS)为您提供安全可靠、可扩展的共享文件存储服务。文件存储可与腾讯云服务器、容器服务、批量计算等服务搭配使用,为多个计算节点提供容量和性能可弹性扩展的高性能共享存储。腾讯云文件存储的管理界面简单、易使用,可实现对现有应用的无缝集成;按实际用量付费,为您节约成本,简化 IT 运维工作。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档