跟我学CSE系列之6:dubbo应用如何接入CSE

这篇博客详细介绍了如何将使用Dubbo的服务平滑迁移到ServiceComb,主要涉及服务提供方和服务消费方的改造,包括替换依赖、修改接口注释、启动入口调整以及配置文件的变更。迁移过程因两者都基于Spring,故工作量相对较小。
摘要由CSDN通过智能技术生成

Dubbo和Java chassis底层都使用了Spring的依赖注入和bean管理系统,所以使用Dubbo的服务迁移到ServiceComb工作量较小, 主要改动在依赖和配置方面。

服务提供方

替换依赖

将对dubbo的依赖替换为对Java chassis的依赖

Dubbo

  <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <version>${dubbo.version}</version>
  </dependency>

Java chassis

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.servicecomb</groupId>
        <artifactId>java-chassis-dependencies</artifactId>
        <version>${java.chassis.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  
  <dependencies>
    <dependency>
      <groupId>io.servicecomb</groupId>
      <artifactId>transport-highway</artifactId>
    </dependency>
    <dependency>
      <groupId>io.servicecomb</groupId>
      <artifactId>transport-rest-vertx</artifactId>
    </dependency>
    <dependency>
      <groupId>io.servicecomb</groupId>
      <artifactId>provider-pojo</artifactId>
    </dependency>
  </dependencies>

替换服务接口注释

以 @Service 注释方式暴露的服务接口,用 @RpcSchema 替代

Dubbo

import com.alibaba.dubbo.config.annotation.Service;

@Service
public class SomeServiceImpl implements SomeService {
  // ...
}

Java chassis

@RpcSchema(schemaId = "someServiceEndpoint")
public class SomeServiceImpl implements SomeService {
  // ...
}

修改提供方启动入口

Dubbo

public class ProviderMain
{
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值