dubbo实例
来源:互联网 发布:你给我的温柔网络歌曲 编辑:程序博客网 时间:2024/06/11 21:17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
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
>cheng.xi</
groupId
>
<
artifactId
>test.dubbo</
artifactId
>
<
packaging
>pom</
packaging
>
<
version
>1.0-SNAPSHOT</
version
>
<
modules
>
<
module
>DubboConsumer</
module
>
<
module
>DubboProvider</
module
>
<
module
>DubboCommon</
module
>
</
modules
>
<
dependencies
>
<
dependency
>
<
groupId
>junit</
groupId
>
<
artifactId
>junit</
artifactId
>
<
version
>4.9</
version
>
</
dependency
>
<
dependency
>
<
groupId
>org.springframework</
groupId
>
<
artifactId
>spring-core</
artifactId
>
<
version
>4.1.3.RELEASE</
version
>
</
dependency
>
<
dependency
>
<
groupId
>org.springframework</
groupId
>
<
artifactId
>spring-test</
artifactId
>
<
version
>4.1.3.RELEASE</
version
>
</
dependency
>
<
dependency
>
<
groupId
>com.alibaba</
groupId
>
<
artifactId
>dubbo</
artifactId
>
<
version
>2.5.3</
version
>
</
dependency
>
<
dependency
>
<
groupId
>com.github.sgroschupf</
groupId
>
<
artifactId
>zkclient</
artifactId
>
<
version
>0.1</
version
>
</
dependency
>
</
dependencies
>
</
project
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
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"
>
<
parent
>
<
artifactId
>test.dubbo</
artifactId
>
<
groupId
>cheng.xi</
groupId
>
<
version
>1.0-SNAPSHOT</
version
>
</
parent
>
<
modelVersion
>4.0.0</
modelVersion
>
<
artifactId
>dubbo.consumer</
artifactId
>
<
dependencies
>
<
dependency
>
<
groupId
>cheng.xi</
groupId
>
<
artifactId
>dubbo.common</
artifactId
>
<
version
>1.0-SNAPSHOT</
version
>
</
dependency
>
</
dependencies
>
</
project
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
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"
>
<
parent
>
<
artifactId
>test.dubbo</
artifactId
>
<
groupId
>cheng.xi</
groupId
>
<
version
>1.0-SNAPSHOT</
version
>
</
parent
>
<
modelVersion
>4.0.0</
modelVersion
>
<
artifactId
>dubbo.provider</
artifactId
>
<
dependencies
>
<
dependency
>
<
groupId
>cheng.xi</
groupId
>
<
artifactId
>dubbo.common</
artifactId
>
<
version
>1.0-SNAPSHOT</
version
>
</
dependency
>
</
dependencies
>
</
project
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
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"
>
<
parent
>
<
artifactId
>test.dubbo</
artifactId
>
<
groupId
>cheng.xi</
groupId
>
<
version
>1.0-SNAPSHOT</
version
>
</
parent
>
<
modelVersion
>4.0.0</
modelVersion
>
<
artifactId
>dubbo.common</
artifactId
>
<
packaging
>jar</
packaging
>
</
project
>
1
2
3
4
5
6
7
8
package
dubbo.common.hello.service;
/**
* Created by cheng.xi on 15/4/12.
*/
public
interface
HelloService {
public
void
sayHello();
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package
dubbo.provider.hello.service.impl;
import
dubbo.common.hello.service.HelloService;
/**
* Created by cmcc on 15/4/12.
*/
public
class
HelloServiceImpl
implements
HelloService {
@Override
public
void
sayHello() {
System.out.println(
"这里是Provider"
);
System.out.println(
"HelloWorld Provider!"
);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package
dubbo.provider.hello.main;
import
org.springframework.context.support.ClassPathXmlApplicationContext;
import
java.io.IOException;
/**
* Created by cheng.xi on 15/4/12.
*/
public
class
StartProvider {
public
static
void
main(String[] args){
ClassPathXmlApplicationContext context =
new
ClassPathXmlApplicationContext(
new
String[]{
"dubbo-provider.xml"
});
context.start();
System.out.println(
"这里是dubbo-provider服务,按任意键退出"
);
try
{
System.in.read();
}
catch
(IOException e) {
e.printStackTrace();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package
dubbo.consumer.hello.main;
import
dubbo.common.hello.service.HelloService;
import
org.junit.Test;
import
org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.test.context.ContextConfiguration;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by cheng.xi on 15/4/12.
*/
@RunWith
(SpringJUnit4ClassRunner.
class
)
@ContextConfiguration
(
"/dubbo-consumer.xml"
)
public
class
StartConsumer {
@Autowired
private
HelloService helloService;
@Test
public
void
test(){
System.out.println(
"dubbo-consumer服务启动,调用!"
);
helloService.sayHello();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?
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-consumer"
/>
<
dubbo:registry
protocol
=
"zookeeper"
address
=
"127.0.0.1:2181"
/>
<
dubbo:reference
id
=
"helloService"
interface
=
"dubbo.common.hello.service.HelloService"
/>
</
beans
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?
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-provider"
/>
<
dubbo:registry
protocol
=
"zookeeper"
address
=
"127.0.0.1:2181"
/>
<
dubbo:protocol
name
=
"dubbo"
port
=
"20880"
/>
<
bean
id
=
"helloService"
class
=
"dubbo.provider.hello.service.impl.HelloServiceImpl"
/>
<
dubbo:service
interface
=
"dubbo.common.hello.service.HelloService"
ref
=
"helloService"
/>
</
beans
>
阅读全文
0 0
- Dubbo实例
- Dubbo实例
- Dubbo实例
- Dubbo实例
- dubbo实例
- Dubbo实例
- Dubbo实例
- dubbo实例
- Dubbo入门实例
- Dubbo学习教程实例
- 阿里dubbo实例测试
- dubbo 实例详解
- Dubbo简介及实例
- Dubbo入门实例
- Dubbo入门实例
- Dubbo入门实例
- dubbo入门实例
- Dubbo入门实例--转载
- TCP/IP簇——ICMP协议概述
- 通过/sys/class/rtc/rtcX/date 获取rtc的时间
- [译] Python Numpy学习资料 (1)
- 仿照VOC2007制作自己的数据集,并在Caffe上训练Faster-RCNN
- Word文档常见的三大问题及其解决方法(珍藏版)
- dubbo实例
- (状态方程, 数学)Codeforces Round #427 C. Star sky
- 一张图看懂移动测试框架关系
- 关于ASCII、Unicode、Char、NChar之间的联系与区别
- 普通队列,循环队列以及链队列的相关操作
- 如何对字符串加密解密
- 如何安装ioncube扩展
- 资源依赖关系查询工具
- Java8新特性Lambda表达式、函数式接口