dubbo的第一次使用心得

第一点:先在linux中安装注册中心zookeeper 获得ip
安装步骤:待完善

第二步:要将dubbo的war包放入到linux tomcat的wabapps下启动Tomcat,如果dubbo和zookeeper不在同一台服务器上,就在dubbo中的war包中config中找到配置文件 修改配置文件的ip地址

第三步:在war包里面的pom配置文件配置dubbo 一个war包配置一个dubbo这样子就形成了soa 也就是分布式
在e3mall-maneger-web pom包下的代码

	<dependency>
		<groupId>com.alibaba</groupId>
		<artifactId>dubbo</artifactId>
		<exclusions>
			<exclusion>
				<groupId>org.springframework</groupId>
				<artifactId>spring</artifactId>
			</exclusion>
			<exclusion>
				<groupId>org.jboss.netty</groupId>
				<artifactId>netty</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
	<dependency>
		<groupId>org.apache.zookeeper</groupId>
		<artifactId>zookeeper</artifactId>
	</dependency>
	<dependency>
		<groupId>com.github.sgroschupf</groupId>
		<artifactId>zkclient</artifactId>
	</dependency>

在e3mall-maneger-web springmvc.xml下的代码

<dubbo:application name="e3-manager-web"/>
<dubbo:registry protocol="zookeeper" address="192.168.154.130:2181"/>	
<dubbo:reference interface="cn.e3mall.service.ItemService" id="itemService" />

在e3mall-maneger-service pom包下的配置

	<dependency>
		<groupId>com.alibaba</groupId>
		<artifactId>dubbo</artifactId>
		<exclusions>
			<exclusion>
				<groupId>org.springframework</groupId>
				<artifactId>spring</artifactId>
			</exclusion>
			<exclusion>
				<groupId>org.jboss.netty</groupId>
				<artifactId>netty</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
	<dependency>
		<groupId>org.apache.zookeeper</groupId>
		<artifactId>zookeeper</artifactId>
	</dependency>
	<dependency>
		<groupId>com.github.sgroschupf</groupId>
		<artifactId>zkclient</artifactId>
	</dependency>

在e3mall-maneger-service applicationContext-service.xml的代码

<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:application name="e3-manager" />
<dubbo:registry protocol="zookeeper" address="192.168.154.130:2181" />
<!-- 用dubbo协议在20880端口暴露服务 -->
<dubbo:protocol name="dubbo" port="20880" />
<!-- 声明需要暴露的服务接口 -->
<dubbo:service interface="cn.e3mall.service.ItemService" ref="itemServiceImpl" timeout="600000"/>

猜你喜欢

转载自blog.csdn.net/qq_42412743/article/details/93761151