关闭

在SpringMVC框架下提供dubbo服务(提供者)

标签: spring mvcdubbo框架
1172人阅读 评论(0) 收藏 举报
分类:
dubbo服务提供者xml配置
********************************************************************************************
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                    
             xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
             xsi:schemaLocation="http://www.springframework.org/schema/beans
                                                 http://www.springframework.org/schema/beans/spring-beans.xsd
                                                 http://code.alibabatech.com/schema/dubbo
                                                 http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <dubbo:application name="${dubbo.application.name}" owner="${dubbo.application.owner}" />
    <!-- 使用zookper暴露发现服务地址 -->
    <dubbo:registry address="${user.dubbo.registry.address}" check="false" />
    <!-- 用dubbo协议在XXX端口暴露服务 -->
    <dubbo:protocol name="dubbo" port="${user.dubbo.export.port}" />
    <bean id="testservice" class="com.user.push.services.TestCalledImpl" />   
    <dubbo:service timeout="5000" loadbalance="random" actives="0" interface="com.user.push.services.TestService"         
    ref="testservice" />
</beans>
********************************************************************************************
说明
application name对应你的应用名;owner对应该应用的维护人员
registry address对应即将发布的服务的目标注册地址,这里使用zooker注册中心
push.dubbo.export.port对应dubbo服务暴露的端口

这样启动服务后,你就能在dubbo管理后台看到你的服务信息了


点击服务,可看到服务详情



注:
如果在xml配置文件中没有添加红色语句,则会报错,提示找不到相应的bean
Error creating bean with name 'com.user.push.services.TestService': Cannot resolve reference to bean 'testservice' while setting bean property 'ref'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'testservice' is defined
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
 at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:760)
 at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:403)
 at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:752)
 at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:239)
 at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1213)
 at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:695)
 at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
 at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
 at org.eclipse.jetty.server.Server.doStart(Server.java:262)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
 at jetty.PushServiceJetty.start(PushServiceJetty.java:79)
 at jetty.PushServiceJetty.main(PushServiceJetty.java:88)
Caused by:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'testservice' is defined
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1095)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:277)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
 at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:760)
 at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:403)
 at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:752)
 at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:239)
 at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1213)
 at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:695)
 at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
 at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
 at org.eclipse.jetty.server.Server.doStart(Server.java:262)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
 at jetty.PushServiceJetty.start(PushServiceJetty.java:79)
 at jetty.PushServiceJetty.main(PushServiceJetty.java:88)


1
0

猜你在找
【直播】机器学习&数据挖掘7周实训--韦玮
【套餐】系统集成项目管理工程师顺利通关--徐朋
【直播】3小时掌握Docker最佳实战-徐西宁
【套餐】机器学习系列套餐(算法+实战)--唐宇迪
【直播】计算机视觉原理及实战--屈教授
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之矩阵--黄博士
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之凸优化--马博士
【套餐】Javascript 设计模式实战--曾亮
查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2849次
    • 积分:59
    • 等级:
    • 排名:千里之外
    • 原创:4篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档