1.maven pom jar包

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springframework.version>3.1.0.RELEASE</springframework.version>
<!-- Logging -->
<slf4j.version>1.7.5</slf4j.version>
<slf4j-log4j12.version>1.7.2</slf4j-log4j12.version>
<log4j.version>1.2.17</log4j.version>
</properties>

<dependencies>

<!-- Logging with SLF4J -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-log4j12.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<scope>provided</scope>
</dependency>
<!-- SPRING -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${springframework.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${springframework.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${springframework.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${springframework.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.4.9</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>spring</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>


2.api工程,对外服务接口的定义

3.core工程,对外服务接口的实现已经配置,服务提供者

<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:application name="ServiceProvider" />
<dubbo:annotation package="com.zookeeper.*" />
<!-- 使用multicast广播注册中心暴露服务地址 -->
<dubbo:registry address="${zookeeper.address}"></dubbo:registry>
 <!-- 用dubbo协议在20880端口暴露服务 -->
<dubbo:protocol name="dubbo" port="20880"></dubbo:protocol>
<!-- 服务提供者过期时间配置 -->
<dubbo:provider timeout="1000000" retries="0" />
<!-- 声明需要暴露的服务接口 -->
<dubbo:service interface="com.zookeeper.api.HelloService" ref="helloService"></dubbo:service>

4.manager工程,对外服务的使用者

<dubbo:application name="ServiceConsumer" />
<!-- 使用multicast广播注册中心暴露服务地址 -->
<dubbo:registry address="${zookeeper.address}"></dubbo:registry>
<!-- 申明需要使用的服务接口 -->
<dubbo:reference id="helloService" interface="com.zookeeper.api.HelloService" />

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐