一、项目介绍
二、项目分解说明 1 . p3dubbo-service 说明:该项目为简单的maven构建项目,无任何依赖引用,只作接口定义 接口定义如下: pom文件说明 2. p3dubbo-service 说明:该项目为接口实现项目,进行业务逻辑编写
接口实现如下: @Service("demoService")
public class DemoServiceImpl implements DemoServiceI {
public String sayHello(String name) {
System.out.println(" -- jeecg-p3-dubbo---say: "+name);
return name + "[jeecg-p3-dubbo]";
}
} |
pom如下:(引入jeecg-p3父POM,增加dubbo依赖支持) <parent>
<groupId>org.p3framework</groupId>
<artifactId>jeecg-p3-pom</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<!-- 接口API -->
<dependency>
<groupId>org.p3dubbo</groupId>
<artifactId>p3dubbo-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- dubbo jar -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</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>
</dependencies> |
Spring dubbo配置文件
3..jeecg-p3-web (启动项目) 说明:该项目为jeecg-p3启动项目,作为服务提供项目,需要引入p3dubbo-service-impl项目 1)引入spring dubbo配置 2)pom引入接口实现项目 启动项目jeecg-p3-web,提供服务(前台先按照zookeeper) 4. p3dubbo-consumer(消费项目) 测试类: public class DubboConsumer {
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "applicationContext.xml" });
context.start();
DemoServiceI demoService = (DemoServiceI) context.getBean("demoService");
String hello = demoService.sayHello("1998");
System.out.println(hello);
}
}
|
|
Spring 配置
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>org.p3dubbo</groupId>
<artifactId>p3dubbo-consumer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.p3framework</groupId>
<artifactId>jeecg-p3-pom</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<!-- api -->
<dependency>
<groupId>org.p3dubbo</groupId>
<artifactId>p3dubbo-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- dubbo jar -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</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>
</dependencies>
</project>
|
测试结果 [1].采用maven方式启动jeecg-p3-web项目
[2].执行类DubboConsumer 客户端: 服务端:
源码下载地址:http://pan.baidu.com/s/1b78fuu 密码:qtx3
|