dubbo 学习(二) 服务方的构建

1.maven下新建工程,pom文件如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>gzh</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 
   <properties>   
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
      <!-- 设置 Spring 的版本 -->   
      <org.springframework.version>3.1.4.RELEASE</org.springframework.version>  
  </properties>  
    
  <dependencies>  
      <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <version>2.5.3</version>
        </dependency>
        
         <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <version>3.4.6</version>
        </dependency>
 
      <dependency>
          <groupId>com.github.sgroschupf</groupId>
         <artifactId>zkclient</artifactId>
         <version>0.1</version>
      </dependency>
    <!-- dubbo end-->  
  </dependencies>
   <build>  
    <finalName>dubboService</finalName>  
  </build>  
  <packaging>war</packaging>
</project>

2.项目结构如下  dubbo_provider.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" />
   <!--  
  <dubbo:annotation package="dp.dubbo.service" /> -->  
  <!--zookeeper注册中心   -->
  <dubbo:registry protocol="zookeeper" address="120.25.59.96:2181" />
    
   <!-- 使用dubbo协议 -->
  <dubbo:protocol name="dubbo" port="20880" />  
 
   <!--  -->  
  <dubbo:service interface="service.testService"  ref="testService"/>  
      
  <bean id="testService"  class="service.testService.impl.testService" />       
     
</beans>

这里可能会出现http://code.alibabatech.com/schema/dubbo/dubbo.xsd不识别从而导致dubbo标签报错。 

解决办法:1.手动下载dubbo.xsd.     2. eclipse->window->preference->xml-->xml catalog->add->location的地址填1中下载的xsd地址,key写配置文件中的地址:http://code.alibabatech.com/schema/dubbo/dubbo.xsd

posted @ 2016-06-20 15:31  像我这样的人  阅读(425)  评论(0编辑  收藏  举报