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)完成整合

posted on   陈惟鲜的博客  阅读(644)  评论(0编辑  收藏  举报

编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?

导航

< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5
点击右上角即可分享
微信分享提示