Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.user.service.UserService. No provider available for the service com.user.service.UserService from the url zookeeper://localhost:2181/com.alibaba.dubbo.registry.RegistryService?application=userservice&dubbo=2.5.3&interface=com.user.service.UserService&methods=add&pid=39796&protocol=dubbo&side=consumer&timeout=15000×tamp=1515132772468 to the consumer 10.100.130.245 use dubbo version 2.5.3
服务提供方:
<?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="userclient"/>
<!--注册中心服务地址-->
<dubbo:registry id="zookeeper" protocol="zookeeper" address="${dubbo.registry.address}"/>
<!--用dubbo协议在30001-->
<dubbo:protocol name="dubbo" port="20880" dispather="all" threadpool="cached" threads="5000"/>
<!--声明需要暴露的服务接口-->
<dubbo:service interface="com.user.service.UserService" ref="userService" version="1.0"
registry="zookeeper" owner="shp"/>
<!--具体服务接口实现-->
<bean id="userService" class="com.user.service.impl.userServiceImpl"/>
</beans>
消费者
<?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="userservice"/>
<dubbo:registry id="zookeeper" protocol="zookeeper" address="${dubbo.registry.address}"/>
<dubbo:reference id="userService" interface="com.user.service.UserService" protocol="dubbo" timeout="15000"/>
</beans>
解决方案: 在 消费者配置文件 dubbo:reference 标签添加 version="1.0",解决。
<dubbo:reference version="1.0" id="userService" interface="com.user.service.UserService" protocol="dubbo" timeout="15000"/>