Dubbo整合Spring(xml形式)
Dubbo 在 spring xml 形式的配置要比SpringBoot 注解形式的配置 可读性要更友好。
springboot项目也推荐使用 xml 形式配置 dubbo
因为Dubbo 是可以具体到方法级别的,使用xml配置起来更直观。(官方也推荐)
本文就来使用 Dubbo 2.7 整合 Spring。
项目结构如下:

父类项目依赖 pom.xml :
<properties>
<dubbo.version>2.7.13</dubbo.version>
<spring.version>4.3.16.RELEASE</spring.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>${spring.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-bom</artifactId>
<version>${dubbo.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-dependencies-zookeeper</artifactId>
<version>${dubbo.version}</version>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

本文详细介绍了如何使用XML配置将Dubbo与Spring进行整合,从创建API、提供者、消费者到测试整个流程,展示了XML配置的可读性和直观性。官方推荐在Spring项目中使用XML配置Dubbo,因为这种方式可以精细到方法级别。通过实例代码展示,包括服务提供者和消费者的配置及实现,最后进行了测试验证。项目源码已上传至GitHub。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



