博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
分布式服务-DUBBOX(五):集成服务生产者
阅读量:5789 次
发布时间:2019-06-18

本文共 3675 字,大约阅读时间需要 12 分钟。

hot3.png

1、demo-base中pom.xml引入dubbo以及zookeeper相关

com.alibaba
dubbo
2.8.4
spring
org.springframework
org.apache.zookeeper
zookeeper
3.4.6
com.101tec
zkclient
0.7

 

2、创建module:demo-provider

1)工程结构如下

114331_duDG_2526015.png

2)pom.xml

demo
com.company
1.0.0
4.0.0
demo-provider
war
com.company
demo-service
1.0.0
com.company
demo-api
1.0.0

3)UserApiImpl.java

package com.company.provider.impl;import com.alibaba.dubbo.config.annotation.Service;import com.company.api.dto.UserDTO;import com.company.api.iapi.UserApi;import com.company.data.model.User;import com.company.service.UserService;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.BeanUtils;import org.springframework.beans.factory.annotation.Autowired;/** * Created by wsyi on 2016/11/29. */@Servicepublic class UserApiImpl implements UserApi {    private static final Logger LOGGER = LoggerFactory.getLogger(UserApiImpl.class);    @Autowired    private UserService userService;    @Override    public UserDTO qryById(Long id) {        UserDTO userDTO = new UserDTO();        User user = userService.qryUserById(id);        BeanUtils.copyProperties(user,userDTO);        return userDTO;    }}

注意:@Service为com.alibaba.dubbo.config.annotation.Service,非Spring中注解Service

4)spring-config.xml

5)spring-provider.xml:

6)dubbo.properties

### Copyright 1999-2011 Alibaba Group.#  # Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at#  #      http://www.apache.org/licenses/LICENSE-2.0#  # Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.###dubbo.container=log4j,springdubbo.application.name=demo-provider-server#dubbo.application.owner=william#dubbo.registry.address=multicast://224.5.6.7:1234dubbo.registry.address=zookeeper://127.0.0.1:2181#dubbo.registry.address=redis://127.0.0.1:6379#dubbo.registry.address=dubbo://127.0.0.1:9090#dubbo.monitor.protocol=registrydubbo.protocol.name=dubbodubbo.protocol.port=20880#dubbo.service.loadbalance=roundrobin#dubbo.log4j.file=logs/dubbo-demo-consumer.log#dubbo.log4j.level=WARNdubbo.service.version=wsy

7)web.xml

contextConfigLocation
classpath:META-INF/spring/spring-*.xml
org.springframework.web.context.ContextLoaderListener

 

3、demo-provider运行

1)启动zookeeper、dubbo-admin服务。

2)将demo-provider部署到tomcat上,启动服务。

3)dubbo-admin服务

144039_xbM0_2526015.png

转载于:https://my.oschina.net/u/2526015/blog/796755

你可能感兴趣的文章
javascript的事件
查看>>
201521123009 《Java程序设计》第1周学习总结
查看>>
年终述职--常见问题分析解答
查看>>
C#_细说Cookie_Json Helper_Cookies封装
查看>>
在mui中创建aJax来请求数据..并展示在页面上
查看>>
spring 之AOP
查看>>
总结 15/4/23
查看>>
Windows 7环境下网站性能测试小工具 Apache Bench 和 Webbench使用和下载
查看>>
C#常见错误解决方法
查看>>
安装cnpm (npm淘宝镜像)
查看>>
Java 面向对象(基础) 知识点总结I
查看>>
读书笔记《自控力》
查看>>
基于神念TGAM的脑波小车(1)
查看>>
ceph集群搭建Jewel版本
查看>>
HttpClient 解释
查看>>
111111
查看>>
在Button上面显示图片,去掉Button的默认样式
查看>>
区域生长算法
查看>>
(转)json+flexgrid+jbox组合运用页面刷新<jsp>
查看>>
hive学习2(Navicat连接hive)
查看>>