在SpringMVC框架下提供dubbo服务(提供者)
来源:互联网 发布:mysql 5.7修改root密码 编辑:程序博客网 时间:2024/04/30 08:39
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"
<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
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}" />
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"
<dubbo:service timeout="5000" loadbalance="random" actives="0" interface="com.user.push.services.TestService"
ref="testservice" />
</beans>
</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
- 在SpringMVC框架下提供dubbo服务(提供者)
- dubbox为dubbo提供REST服务(dubbox + springmvc)
- DUBBO分布式服务框架与SpringMVC+Zookeeper实现服务提供和消费
- dubbo 服务提供者初始
- dubbo服务提供者在tomcat启动失败的问题
- dubbo 搭建 服务提供者(五)
- dubbo 服务提供者 心跳机制
- dubbo--服务提供者类图
- dubbo源码浅析(三)-服务提供者初始化
- Dubbo消费端直连服务提供者(开发调试)
- 服务提供者框架(Service Provider Framework)
- 服务提供者框架(Service Provider Framework)
- 服务提供者框架(Service Provider Framework)
- 服务提供者框架(Service Provider Framework)
- 服务提供者框架(Service Provider Framework)
- 服务提供者框架
- 服务提供者框架
- 服务提供者框架
- C++堆栈区别
- 短信发送器
- URI和URL的区别
- linux下安装RabbitMQ消息机制
- CentOS7 初次安装记录(五)配置 apache 虚拟主机
- 在SpringMVC框架下提供dubbo服务(提供者)
- bat-PUSHD和POPD
- 用户登录和注销
- Selenium+Java自动化学习之路-----------环境搭建
- xml文档的生成与解析头文件字符集的设定
- DB_SQL_ERROR
- 电话拨号器
- Android Spinner的ArrayAdapter和SpinnerAdapter注意事项
- 什么是Oracle的分区表?