本地Dubbo项目搭建测试例子Word文档格式.docx
- 文档编号:15803387
- 上传时间:2022-11-16
- 格式:DOCX
- 页数:45
- 大小:4.22MB
本地Dubbo项目搭建测试例子Word文档格式.docx
《本地Dubbo项目搭建测试例子Word文档格式.docx》由会员分享,可在线阅读,更多相关《本地Dubbo项目搭建测试例子Word文档格式.docx(45页珍藏版)》请在冰豆网上搜索。
syncLimit:
集群中的follower服务器与leader服务器之间请求和应答之间能容忍的最多心跳数(tickTime的数量)。
dataDir:
Zookeeper保存数据的目录,默认情况下,Zookeeper将写数据的日志文件也保存在这个目录里。
dataLogDir:
Zookeeper保存日志文件的目录。
clientPort:
客户端连接Zookeeper服务器的端口,Zookeeper会监听这个端口,接受客户端的访问请求。
==========================代码如下=====================================
#Thenumberofmillisecondsofeachtick
tickTime=2000
#Thenumberofticksthattheinitial
#synchronizationphasecantake
initLimit=10
#Thenumberofticksthatcanpassbetween
#sendingarequestandgettinganacknowledgement
syncLimit=5
#thedirectorywherethesnapshotisstored.
#donotuse/tmpforstorage,/tmphereisjust
#examplesakes.
dataDir=/data
#theportatwhichtheclientswillconnect
clientPort=2181
#themaximumnumberofclientconnections.
#increasethisifyouneedtohandlemoreclients
#maxClientCnxns=60
#
#Besuretoreadthemaintenancesectionofthe
#administratorguidebeforeturningonautopurge.
#http:
//zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#ThenumberofsnapshotstoretainindataDir
#autopurge.snapRetainCount=3
#Purgetaskintervalinhours
#Setto"
0"
todisableautopurgefeature
#autopurge.purgeInterval=1
即可。
2)路径修改
dataDir=C:
/Users/issuser/Desktop/service1/data
dataLogDir=C:
/Users/issuser/Desktop/service1/log
clientPort=2183
创建项目
做服务端:
1)创建一个web项目:
DubboZookeeper作为服务端。
2)定义一个实体类:
User
publicclassUser{
@Override
publicStringtoString(){
return"
User[name="
+name+"
age="
+age+"
sex="
+sex+"
]"
;
}
privateStringname;
privateintage;
privateStringsex;
publicStringgetName(){
returnname;
publicvoidsetName(Stringname){
this.name=name;
publicintgetAge(){
returnage;
publicvoidsetAge(intage){
this.age=age;
publicStringgetSex(){
returnsex;
publicvoidsetSex(Stringsex){
this.sex=sex;
}
3)定义一个service接口:
DemoService
publicinterfaceDemoService{
StringsayHello(Stringname);
publicListgetUsers();
4)定义一个service接口的实现类,DemoServiceImpl
publicclassDemoServiceImplimplementsDemoService{
publicStringsayHello(Stringname){
Hello"
+name;
publicListgetUsers(){
Listlist=newArrayList();
Useru1=newUser();
u1.setName("
jack"
);
u1.setAge(20);
u1.setSex("
男"
Useru2=newUser();
u2.setName("
tom"
u2.setAge(21);
u2.setSex("
女"
Useru3=newUser();
u3.setName("
rose"
u3.setAge(19);
u3.setSex("
list.add(u1);
list.add(u2);
list.add(u3);
returnlist;
5)创建一个dao的测试类Provider:
(使用JUnit测试)
publicclassProvider{
@Before
publicvoidsetUp()throwsException{
@Test
publicvoidtestMain()throwsIOException{
ClassPathXmlApplicationContextcontext=newClassPathXmlApplicationContext(newString[]{"
applicationContext.xml"
});
context.start();
System.in.read();
//按任意键退出
6)创建XML配置文件:
applicationContext.xml(注意:
此处的路径必须是项目的路径,能ctrl+鼠标点进去)
<
?
xmlversion="
1.0"
encoding="
UTF-8"
>
beansxmlns="
http:
//www.springframework.org/schema/beans"
xmlns:
xsi="
//www.w3.org/2001/XMLSchema-instance"
dubbo="
xsi:
schemaLocation="
//www.springframework.org/schema/beans
http:
//www.springframework.org/schema/beans/spring-beans.xsd
"
!
--具体的实现bean-->
<
beanid="
demoService"
class="
com.unj.dubbotest.provider.DemoServiceImpl"
/>
user"
com.unj.du
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 本地 Dubbo 项目 搭建 测试 例子