• 首页
  • 产品中心
    • 数式Oinone四大产品

      低代码开发平台无代码开发平台集成开发平台AI大模型开发
    • 数式Oinone体系能力

      用户与组织权限管理文件管理消息中心国际化业务审计
    • 数式Oinone核心产品特性

      低无一体面向软件公司场景无限制应用级扩容可分可合
  • 服务中心
    • 客户服务

      预约演示方案咨询私有部署找人定制
    • 开发者

      问答下载
    • Oinone学院

      社区学习

    《精讲面向软件公司的低代码平台——以Oinone为例》

  • 合作伙伴
    渠道申请伙伴名录专家库
  • 关于数式
0571-88757863

Project Integration:Nacos as a Registration Center:How to Invoke SpringCloud Services of Other Systems?


I. Overview

As a powerful registration center, Nacos can provide key support such as service registration and discovery for multiple microservice frameworks like Dubbo and SpringCloud.

Currently, Oinone's underlying layer defaults to using Dubbo as the microservice protocol for invocation. However, if there is a requirement in the project to invoke SpringCloud services provided by other systems, Oinone does not restrict developers from writing relevant code.

In this case, developers can refer to the official documentation of Nacos or SpringCloud. As long as common issues such as Jar package conflicts are avoided in practical application, many functional extensions are available for developers to use flexibly, so as to meet the diversified business needs of the project and help build a richer and more efficient microservice architecture system.

Warning:

Nacos, SpringCloud, and SpringCloudAlibaba have strict dependency version requirements: Click to view

II. Specific Examples:

(Ⅰ) Adding Dependencies to the Project

Introduce compatible versions in the main pom:

<dependencyManagement>
  <dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-dependencies</artifactId> 
    <version>2.2.7.RELEASE</version> <!-- Currently compatible version -->
    <type>pom</type>
    <scope>import</scope>
  </dependency>
</dependencyManagement>

Introduce dependencies in the pom of the used module:

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

(Ⅱ) Configuring application.yml

spring:
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
        username: nacos
        password: nacos

Note: For more YAML configurations, please go to Module API for consultation.

(Ⅲ) Adding Annotations to the Startup Class

@EnableDiscoveryClient
@EnableFeignClients
public class NacosConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(NacosConsumerApplication.class, args);
    }
}

(Ⅳ) Verification

Create a Feign Client interface


import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;

@FeignClient(name = "nacos-demo") // Specify the name of the target service
public interface ProviderClient {

    @GetMapping("/hello")
    String hello();
}

Create a Controller to invoke the Feign Client

@RestController
public class ConsumerController {

    private final ProviderClient providerClient;

    public ConsumerController(ProviderClient providerClient) {
        this.providerClient = providerClient;
    }

    @GetMapping("/hello")
    public String hello() {
        return providerClient.hello();
    }
}

Access http://localhost:8082/hello in the browser You will see the response returned by the service provider.

Edit this page
Last Updated:1/15/26, 4:02 AM
Prev
Page Design:Customizing User Center Menu
Next
Project Integration:How Oinone Supports Building Distributed Projects
默认页脚
Copyright © 2026 Mr.Hope