Updated on 2025-06-30 GMT+08:00

Overview

Scenario

You can package and deploy the service code to CAE. Only the Nacos engine configuration needs to be added to the deployed component configuration to automatically connect to the Nacos engine. You need not manually modify the service code configuration file to prevent misoperations.

This section describes how to use the CAE source code deployment capability to automatically deploy a provider service and a consumer service, helping you experience automatic access to the Nacos engine.

Process Comparison

Original Nacos interconnection process:

New Nacos interconnection process:

Principles

In Spring Cloud applications, the priority of system environment variables is higher than that of configuration files. Therefore, if parameters are configured in system environment variables, the system preferentially uses the parameters in the environment variables. To automatically connect to the Nacos engine, CAE automatically adds the SPRING_CLOUD_NACOS_DISCOVERY_SERVERADDR and SPRING_CLOUD_NACOS_CONFIG_SERVERADDR environment variables to the component. In this way, the system can correctly connect to the Nacos engine even if these parameters are not configured in the configuration file.

Note: If you configure Nacos registry and discovery parameters with a higher priority than environment variables, the Nacos interconnection may be abnormal. For example, if --spring.cloud.nacos.discovery.server-addr=nacos.com is added to the startup command, the corresponding configuration in the environment variables will be overwritten. As a result, the component cannot connect to Nacos properly. Therefore, when configuring Nacos parameters, pay attention to the priority to ensure that Nacos can be correctly interconnected.