由于我们没有使用maven,楼主就自己查资料搭建了一套dubbo+zookpeer+springMVC
来源:互联网 发布:单片机工资高吗 编辑:程序博客网 时间:2024/05/13 15:29
这段时间楼主本来想学习一下dubbo+zookpeer+spring,找到的资料全都是使用maven,楼主很头疼,就自己动手搭建了一个框架,所有的资料都是楼主手动查找的。下面楼主自己说一下过程。(工程见附件)
1 首先 下载zookpeer ,这个需要跑起来,楼主下载的zookpeer是zookeeper-3.5.2-alpha.tar版,这个不懂的要看资料,楼主提示一点,楼主是在window下起来的,之前楼主用的jdk1.8 一直跑不起来,后来楼主用jdk1.7 还是不行 一直报java_home 错误,这是因为java-home 路径不对 重新配置环境
2 下载一个dubbo-admin-2.4.1 war 放在webapps 下, 在这里楼主提示一下 在dubbo-admin-2.4.1,在dubbo-admin-2.4.1\WEB-INF下有一个dubbo.properties,这里的端口 要和 zookpeer 里面conf下的zoo配置里面的port一样,这个时候可以测试一下是否跑起来了,运行一下tomcat,输入http://localhost:8080
在managerApp下面有一个dubbo-admin-2.4.1 项目 ,点击进入,出现如图页面就成功了
3,完成上面的两步,就代表环境已经搭建完成,然后开始创建消费者和提供者两个工程,我用的是springmvc ,看一下配置
1>提供者
先看一mvc-servlet配置
<?xml version="1.0" encoding="UTF-8"?>
-<beans default-lazy-init="false" default-autowire="byName" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd " xmlns:task="http://www.springframework.org/schema/task" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans">
<!-- 启动注解,注册服务,如验证框架、全局类型转换器-->
<mvc:annotation-driven/>
<!-- 启动自动扫描 -->
<context:component-scan base-package="com.**"> </context:component-scan>
<!-- 配置视图解析器 -->
<!-- prefix和suffix:查找视图页面的前缀和后缀(前缀[逻辑视图名]后缀), 比如传进来的逻辑视图名为WEB-INF/jsp/hello,则该该jsp视图页面应该存放在“WEB-INF/jsp/hello.jsp”; -->
-<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property value="org.springframework.web.servlet.view.JstlView" name="viewClass"/>
<property value="/" name="prefix"/>
<property value=".jsp" name="suffix"/>
</bean>
<import resource="providerContext.xml"/>//这里引入提供者配置
</beans>
提供者配置文件
<?xml version="1.0" encoding="UTF-8"?>
-<beans default-lazy-init="false" default-autowire="byName" xsi:schemaLocation="http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans">
<!-- 配置可参考 http://dubbo.io/User+Guide-zh.htm -->
<!-- 服务提供方应用名,用于计算依赖关系 -->
<dubbo:application name="dubbo-provider"/>
<!-- 定义 zookeeper 注册中心地址及协议 -->
<dubbo:registry address="127.0.0.1:2181" protocol="zookeeper"/>
<!-- 定义 Dubbo 协议名称及使用的端口,dubbo 协议缺省端口为 20880,如果配置为 -1 或者没有配置 port,则会分配一个没有被占用的端口 -->
<dubbo:protocol name="dubbo" port="20883"/>
<!-- 声明需要暴露的服务接口 -->
<dubbo:service ref="provderService" interface="com.service.ProvderService"/>
<!-- 和本地 bean 一样实现服务 -->
<bean class="com.service.serviceImpl.ProvderServiceImpl" id="provderService1"/>
</beans>
>
消费者 的mvc-servlet 基本和提供者一样只是引入的文件不同<import resource="consumerContext.xml"/>
看一下消费者的 配置文件
<?xml version="1.0" encoding="UTF-8"?>
-<beans 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" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans">
<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:application name="webapp-customer"/>
<!-- 使用zookeeper注册中心暴露服务地址 -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- 生成远程服务代理,可以和本地bean一样使用provderService1 这里的id 是我们注入的提供者的id 千万别搞错了 在controler里面的那个 不要搞错了 -->
<dubbo:reference check="false" interface="com.service.ProvderService" id="provderService1"/>//
</beans>
4 创建工程,就可以启动项目了,记住一定要让有这个dubbo-admin-2.4.1项目的tomcat先跑起来,提供者和消费者要想一起启动<dubbo:reference check="false" interface="com.service.ProvderService" id="provderService1"/> 加上一个 check="false" 我这里简单的描述一下 具体工程在下面的连接处下载
具体工程看http://download.csdn.net/download/l_mr_l/10040831,里面包括所有的jar 和所需要的工具以及环境和代码,代码包括 本地和用springmvc两个测试demo
- 由于我们没有使用maven,楼主就自己查资料搭建了一套dubbo+zookpeer+springMVC
- 搭建 maven+springmvc+dubbo
- 使用maven搭建一套web
- 使用Maven搭建SpringMVC
- 使用Maven搭建SpringMVC
- 使用Maven搭建SpringMVC
- 使用Maven搭建SpringMVC
- 使用Maven搭建SpringMVC
- 20多岁,就应该买一套房子了。 如果没有自己的房子还在父母房子中,空间不够了。
- XenServer没有自己的文件系统,也就没有自己的ISO Libery,给我们创建虚拟机带来了不少困扰,使用正文这个方法可以不用先安装FileServer
- 分布式服务框架--dubbo+zookpeer
- 分布式服务框架--dubbo+zookpeer
- zookpeer 伪集群搭建及 C API使用
- 使用Maven搭建SpringMVC项目
- 基于maven的spring+springMvc+MyBatis+Dubbo架构的搭建
- maven下搭建springMVC+mybatis+mysql+zookeeper+dubbo
- maven+springmvc+dubbo+zookeeper
- maven+springmvc+dubbo+zookeeper
- mvp okhttp3,网络请求
- RecyclerView源码详解(第二篇ItemDecoration源码详解)
- 调试运行网页版Snap4Arduino链接Arduino主板的过程
- 第八周项目1-顺序串算法库
- 奇葩说经典语录
- 由于我们没有使用maven,楼主就自己查资料搭建了一套dubbo+zookpeer+springMVC
- PHP 中的sha1()和MD5()函数漏洞
- 后端传回一个String类型的js脚本语句 前端如何解析
- Codeforces Round #400 (Div. 1 + Div. 2, combined) C
- Solr性能调优。
- java常用类库---日期操作类(2)
- DrawerLayout实现侧滑菜单效果
- Linux下的tar压缩解压缩命令详解
- sssm