maven工程中dubbo与spring整合

1)引入相应jar包

<!-- 引入dubbo服务 start-->
        <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>com.github.sgroschupf</groupId>
            <artifactId>zkclient</artifactId>
            <version>0.1</version>
        </dependency>
        <!-- 引入dubbo服务 end-->

2)相应配置信息dubbo.xml

<?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="demo-system" owner="demo-system"/>

    <dubbo:registry protocol="zookeeper" address="192.168.10.102:2181"/>

    <dubbo:protocol name="dubbo" port="-1" heartbeat="2000"/>

    <!-- 调用服务接口 -->
    <dubbo:reference id="dictionaryService" interface="com.iafclub.demo.remote.DictionaryService" check="false" timeout="10000"/>

    <!--提供服务接口-->
    <dubbo:service interface="com.iafclub.demo.remote.DictionaryService" ref="dictionaryServiceImpl"/>
</beans>

3)web.xml配置

    <!-- ContextLoaderListener初始化Spring上下文时需要使用到的contextConfigLocation参数 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <!-- 配置spring.xml和spring-mybatis.xml这两个配置文件的位置,固定写法 -->
        <param-value>
            classpath:spring.xml,
            classpath:spring-mybatis.xml,
            classpath:spring-activitymq.xml,
            classpath:dubbo.xml,
            classpath:spring-redis.xml
        </param-value>
    </context-param>

4)完成整合

时间: 2024-08-26 11:59:30

maven工程中dubbo与spring整合的相关文章

maven工程中警告[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [警告]使用时平台编码格式(GBK actually)进行解析的文件资源,也就是说,构建是依赖于平台的! 错误原因:一些源文件的编码格式并不是工具平台的默认的解析格式,二者有冲突,所以报错 解决方法:在maven工程中的父工程POM中加入以下代码" <properties

maven工程中读取resource目录下配置文件

在maven工程中,我们会将配置文件放到src/main/resources下面,例如 我们需要确认resource 下的文件编译之后存放的位置. 它编译的路径直接位于classes下面,这个路径其实就是classPath的路径,所以,在resources 根目录下的配置文件其实就是 classPath的路径. // 1. 声明静态数据源成员变量private static DataSource ds; // 2. 创建连接池对象static { Properties pp = new Prop

本地jar包在maven工程中pom引用

背景 ??在使用Maven的过程中,经常碰到有些jar包在中央仓库没有的情况.如果公司有私服,那么就把jar包安装到私服上.如果没有私服,那就把jar包安装到本地Maven仓库.下面是如何把jar包导入本地maven仓库. 解决方法 1.确定包信息 groupId:设置项目代码的包名(一般用公司或组织名) artifactId:设置项目名或模块名 version:版本号 packaging:什么类型的文件(jar包) filePath:指定jar文件路径与文件名(同目录只需文件名) 2.在工程根

【Dubbo实战】 Dubbo+Zookeeper+Spring整合应用篇-Dubbo基于Zookeeper实现分布式服务(转)

Dubbo与Zookeeper.Spring整合使用 Dubbo采用全Spring配置方式,透明化接入应用,对应用没有任何API侵入,只需用Spring加载Dubbo的配置即可,Dubbo基于Spring的Schema扩展进行加载. 一:单机模式安装zookeeper 1,下载zookeeper注册中心,下载地址:http://www.apache.org/dyn/closer.cgi/zookeeper/ 下载后解压即可,进入E:\zookeeper-3.3.6\zookeeper-3.3.6

【Dubbo实战】 Dubbo+Zookeeper+Spring整合应用篇(二)

Dubbo与Zookeeper.Spring整合使用 Dubbo采用全Spring配置方式,透明化接入应用,对应用没有任何API侵入,只需用Spring加载Dubbo的配置即可,Dubbo基于Spring的Schema扩展进行加载. 一:单机模式安装zookeeper 1,下载zookeeper注册中心,下载地址:http://www.apache.org/dyn/closer.cgi/zookeeper/ 下载后解压即可,进入E:\zookeeper-3.3.6\zookeeper-3.3.6

在maven工程中搭建SSM框架的错误总结

第一次搭建Maven工程走了很多弯路,现在总算把项目搭起来并且能正常运行了.故总结一下教训 1.在建立Maven工程前,先确定成功下载安装了Maven.  命令行用 mvn -v  检验 找到Maven的安装目录C:\Program Files\apache-maven-3.5.2\conf中的setting.xml文件,打开后配置本地仓库 <localRepository>C:/Users/lts/.m2/repository</localRepository>  (注意这里的&

如何在maven工程中加载oracle驱动

maven中引入oracle驱动报错Missing artifact com.oracle:ojdbc14:jar:10.2.0.4.0 时间:2015年09月22日  浏览:9361次 在maven中央库中查找ojdbc,发现最新的版本是10.2.0.4.0,然后在maven项目中引入ojdbc,发现报错Missing artifact com.oracle:ojdbc14:jar:10.2.0.4.0,如下图1所示: 图1:Missing artifact 发现中央库中明明是有的,但是在项目

maven工程中,spring mvc @ResponseBody的使用

1.配置web.xml文件(确保已经导入了spring中的jar包) <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="ht

httpclient版本冲突,maven工程中传递依赖导致的版本冲突

A服务发送http请求调用B服务时,出现异常信息:2020-03-23 10:15:14.001:WARN:oejs.ServletHandler:qtp760563749-27: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/apache/http/util/Argsat