All Products
Search
Document Center

Microservices Engine:Migrate application configurations from Apollo to MSE Nacos

Last Updated:Mar 10, 2026

When you move from a self-managed Apollo configuration center to Alibaba Cloud Microservices Engine (MSE) Nacos, you need to migrate two things: the configuration data itself and the application code that reads it. This guide walks you through both, from exporting Apollo configurations to verifying the migrated application.

The migration follows six steps:

  1. Export configurations from Apollo

  2. Convert the exported file to Nacos format

  3. Import configurations into MSE Nacos

  4. Update the Maven dependency

  5. Update the application code

  6. Switch the configuration endpoint

How Apollo concepts map to Nacos

Apollo and Nacos organize configurations differently. Before you start, understand how the two models relate to each other.

Apollo parameterNacos parameterNotes
envinstanceEach Apollo environment maps to a Nacos instance or a separate namespace within an instance.
appIdappNameIdentifies the application.
clustergroupDirect mapping.
{appId}.{namespace}.{format}dataIdThe three Apollo fields concatenate to form the Nacos dataId.

Configurations in different Apollo environments can map to different Nacos instances or different namespaces within a single instance. Choose whichever approach fits your deployment model.

Prerequisites

Before you begin, make sure that you have:

  • An MSE Nacos Professional Edition instance. For instructions, see Create a Nacos engine

  • Access to the self-managed Apollo console

Step 1: Export configurations from Apollo

Export your Apollo configurations using one of the following methods.

Method 1: Export from the Apollo console (recommended)

  1. Log on to the self-managed Apollo console. In this example, you can access the Apollo console at http://81.68.181.139.

  2. On the My Applications page, click the name of the target application.

  3. In the upper-right corner of the application details page, choose Administrator Tools > Configure Export and Import.

  4. On the Configure Export and Import page, select the export environment and click Export.

Note

Export each environment separately. Each export produces a .zip file for that environment.

Method 2: Export by running an SQL query

If your Apollo version does not support file export, query the database directly. Run the following SQL statement and save the results as a .json or .xlsx file:

SELECT DISTINCT
    a.NamespaceId,
    b.NamespaceName,
    c.`Comment` AS 'NamespaceDesc',
    b.AppId,
    b.ClusterName,
    a.Key,
    a.Type,
    a.Value,
    a.Comment,
    a.LineNum
FROM ITEM a
LEFT JOIN Namespace b ON a.NamespaceId = b.id
LEFT JOIN AppNamespace c ON c.Name = b.NamespaceName
WHERE a.IsDeleted = 0
ORDER BY a.NamespaceId, a.LineNum;

Step 2: Convert the exported file

Convert the exported file from Step 1 (.zip, .json, or .xlsx) to a format that MSE Nacos can import.

  1. Download the format conversion tool:

       curl -O https://msesync.oss-cn-hangzhou.aliyuncs.com/ApolloConfigTransfer.jar
  2. Run the conversion tool. Replace <exported-file-path> with the full path to the exported Apollo file:

       java -DsourceFilePath=<exported-file-path> -jar ApolloConfigTransfer.jar
  3. After the tool finishes, a file named nacos_config_import_{original-filename}_{timestamp}.zip appears in the current directory. This file is ready for import.

Step 3: Import configurations into MSE Nacos

  1. Log on to the MSE console and select a region in the top navigation bar.

  2. In the left-side navigation pane, choose Microservices Registry > Instances. Click the name of your Nacos instance.

  3. In the left-side navigation pane, choose Configuration Management > Configurations.

  4. Select the target namespace from the Namespace drop-down list.

  5. Click Import Configuration and upload the .zip file from Step 2.

After the import completes, your Apollo configurations are available in MSE Nacos.

Step 4: Update the Maven dependency

Replace the Apollo client dependency with the Spring Cloud Alibaba Nacos Config starter in your pom.xml.

Before (Apollo):

<dependency>
    <groupId>com.ctrip.framework.apollo</groupId>
    <artifactId>apollo-client</artifactId>
    <version>{apollo.version}</version>
</dependency>

After (Spring Cloud Alibaba Nacos):

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
    <version>2.2.10</version>
</dependency>

Version compatibility

Choose the spring-cloud-starter-alibaba-nacos-config version that matches your Spring Cloud Alibaba version:

Spring Cloud Alibaba versionRecommended Nacos Config starter version
2023.x2023.0.3.2
2022.x2022.0.0.2
2021.x2021.0.6.2
2.2.x2.2.11

Step 5: Update the application code

Apollo supports several dynamic configuration patterns. Replace each pattern with its Nacos equivalent as described below.

@Value annotation (no changes required)

The @Value annotation works with Spring Cloud Alibaba without code changes. Add @RefreshScope to the bean to enable dynamic refresh:

@RestController
@RefreshScope
public class DemoController {

    @Value("testKey")
    String testKey = "value";

    @RequestMapping("/valuekey")
    public String getNacosTestKey() {
        return testKey;
    }
}

Replace @ApolloConfig with @ConfigurationProperties

The @ApolloConfig annotation auto-injects property values into a Spring bean. Replace it with the standard Spring @ConfigurationProperties annotation:

@Configuration
@ConfigurationProperties
public class CNStackInfoConfig {

    private String name;
    private int customerCount;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCustomerCount() {
        return customerCount;
    }

    public void setCustomerCount(int customerCount) {
        this.customerCount = customerCount;
    }
}

Replace the Apollo Config API with @NacosConfig

If your code calls the Apollo Config API to get property values:

// Apollo Config API
ConfigService.getAppConfig().getProperty("testkey", "defaulyv1");
ConfigService.getAppConfig("namespace").getProperty("testkey", "defaulyv1");

Replace it with @NacosConfig and Properties.getProperty():

@NacosConfig(dataId = "appId1.application.properties", group = "group")
Properties nacosConfigProperties;

private void method() {
    String value = nacosConfigProperties.getProperty("key", "defaultValue");
}

Replace ApolloConfigChangeListener with @NacosConfigKeysListener

If your code uses @ApolloConfigChangeListener to react to configuration changes:

// Apollo listener
@ApolloConfigChangeListener(interestedKeyPrefixes = {"data."})
public void apolloNotify(ConfigChangeEvent configChangeEvent) {
    System.out.println(configChangeEvent.changedKeys());
}

Replace it with @NacosConfigKeysListener:

// Nacos listener
@NacosConfigKeysListener(
    dataId = "appId1.application.properties",
    group = "group",
    interestedKeyPrefixes = {"data."}
)
public void apolloNotify(ConfigChangeEvent configChangeEvent) {
    System.out.println(configChangeEvent.changedKeys());
}

For detailed annotation usage, see Annotations of Nacos configuration centers for Spring Cloud applications.

Step 6: Switch the configuration endpoint

Replace the Apollo bootstrap configuration with the Nacos configuration endpoint.

Before (Apollo):

## Apollo configurations
# Environment: -Dappllo.env={env}
apollo.meta=http://127.0.0.1:8070
apollo.bootstrap.enabled=true
# Namespaces to load
apollo.bootstrap.namespaces=application,namespace1
# Cluster
apollo.bootstrap.cluster=default
# Application ID
app.id=app1

After (Nacos):

# Import specific configurations by dataId and group
spring.config.import[0]=nacos:app1.application.properties?group=default&refreshEnabled=true
spring.config.import[1]=nacos:app1.namespace1.properties?group=default&refreshEnabled=true

# MSE Nacos endpoint
spring.cloud.nacos.config.server-addr=mse-xxx-p.nacos-ans.mse.aliyuncs.com

# MSE Nacos namespace (use the namespace ID from the MSE console)
spring.cloud.nacos.config.namespace=<namespace-id>

Replace the following placeholders with your actual values:

PlaceholderDescriptionExample
mse-xxx-p.nacos-ans.mse.aliyuncs.comMSE Nacos instance endpointmse-abc123-p.nacos-ans.mse.aliyuncs.com
<namespace-id>Namespace ID from the MSE console5babe1ee-1352-xxxx-bd7b-7e7ce892e2ab

After you update the configuration, restart the application.

Verify the migration

After the application restarts, verify that the migration succeeded:

  1. Check configuration loading: Review the application startup logs. Confirm that configurations load from the Nacos endpoint without errors.

  2. Validate dynamic refresh: Change a configuration value in the MSE Nacos console. Verify that the application picks up the new value without a restart.

  3. Test application behavior: Run your functional test suite. Confirm that the application behaves as expected with the migrated configurations.

Note

Monitor the application for a period after migration. After you confirm that everything works correctly, decommission the self-managed Apollo configuration center.