provider
<?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-2.5.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 1,配置应用名称 -->
<dubbo:application name="jt-dubbo-cart"/>
<!-- 2,配置zookeeper的ip地址和端口号 -->
<dubbo:registry timeout="9000000" address="zookeeper://192.168.132.140:2181"></dubbo:registry>
<!-- 3,设置端口号,消费者通过网络访问这个提供者 -->
<dubbo:protocol port="20886" name="dubbo"></dubbo:protocol>
<!-- 4,配置实现类,创建对象 -->
<bean class="com.jt.cart.service.CartServiceImpl" id="cartServiceImpl"></bean>
<!-- 5, 公开对象,公开后,消费者只能通过网络访问-->
<dubbo:service interface="com.jt.cart.service.CartService" ref="cartServiceImpl">
</dubbo:service>
</beans>
consumer
<?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-2.5.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 1, 配置应用名称 -->
<dubbo:application name="jt-dubbo-cart" />
<!-- 2, 配置zookeeper -->
<dubbo:registry timeout="900000"
address="zookeeper://192.168.132.140:2181"></dubbo:registry>
<!-- 3,配置接口 -->
<!-- spring LoginController 调LoginService,从spring框架有@service LoginServiceImpl
@autowired LoginService @autowired CartService 加了refrence标签,@autowired CartService
spring调dubbo框架,dubbo框架从zookeeper找到实现类 -->
<dubbo:reference timeout="50000" check="false"
id="cartServiceImpl" interface="com.jt.cart.service.CartService"></dubbo:reference>
<dubbo:reference timeout="50000" check="false" id="orderService"
interface="com.jt.order.service.OrderService"></dubbo:reference>
<dubbo:reference timeout="50000" check="false" id="searchServiceervice"
interface="com.jt.search.service.SearchService"></dubbo:reference>
</beans>