All Products
Search
Document Center

Serverless App Engine:Host Dubbo applications on SAE

Last Updated:Apr 01, 2026

This topic walks you through building a sample Dubbo microservice application locally with XML configuration and deploying it to Serverless App Engine (SAE). The application consists of a service provider and a service consumer, both using Nacos as the service registry. After deployment, SAE automatically replaces the local Nacos registry address—no configuration changes are required.

Prerequisites

Before you begin, make sure you have:

  • Maven installed and configured in your environment variables

  • A local Nacos Server running in standalone mode (see the steps below)

Set up Nacos Server

  1. Download and decompress the Nacos Server package.

  2. Go to the nacos/bin directory and start Nacos Server:

    • Linux, Unix, or macOS: ``bash sudo sh startup.sh -m standalone ``

    • Windows: ``bash startup.cmd -m standalone ``

standalone starts Nacos in standalone mode instead of cluster mode. If double-clicking startup.cmd on Windows fails, open the file and set MODE="standalone" manually. For details, see Quick Start for Nacos.

Version note: Dubbo 2.7.x and Dubbo 3.0.x reached end of life in March 2023. This topic uses Dubbo 3.2.15.

Step 1: Create a provider

Create a Maven project locally, define the service interface, configure XML-based service registration, and start the provider.

1.1 Create a Maven project and add dependencies

  1. Use an IDE (such as IntelliJ IDEA or Eclipse) to create a Maven project.

  2. Add the following dependencies to pom.xml:

    <dependencies>
    
        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo</artifactId>
            <version>3.2.15</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-registry-nacos</artifactId>
            <version>3.2.15</version>
        </dependency>
    
        <dependency>
            <groupId>com.alibaba.nacos</groupId>
            <artifactId>nacos-client</artifactId>
            <version>1.1.1</version>
        </dependency>
    </dependencies>

1.2 Define the service interface

All Dubbo services are defined through interfaces.

  1. In src/main/java, create the package com.alibaba.edas.

  2. In com.alibaba.edas, create the IHelloService interface:

    package com.alibaba.edas;
    
    public interface IHelloService {
        String sayHello(String str);
    }
  3. In com.alibaba.edas, create the IHelloServiceImpl implementation class:

    package com.alibaba.edas;
    
    public class IHelloServiceImpl implements IHelloService {
        public String sayHello(String str) {
            return "hello " + str;
        }
    }

1.3 Configure the Dubbo service

  1. In src/main/resources, create provider.xml.

  2. Add the Spring and Dubbo XML namespaces:

    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
    xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
    http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
  3. Expose the service interface and point to the local Nacos Server:

    ItemValueNote
    Registry addressnacos://127.0.0.1:8848Points to your local Nacos Server. After deploying to SAE, this address is automatically replaced with the SAE-managed registry—no code change needed.
    Nacos port8848Fixed; do not change.
    <dubbo:application name="demo-provider"/>
    
    <dubbo:protocol name="dubbo" port="28082"/>
    
    <dubbo:service interface="com.alibaba.edas.IHelloService" ref="helloService"/>
    
    <bean id="helloService" class="com.alibaba.edas.IHelloServiceImpl"/>
    
    <dubbo:registry address="nacos://127.0.0.1:8848" />

    Key configuration:

1.4 Start the provider

  1. In com.alibaba.edas, create the Provider class:

    package com.alibaba.edas;
    
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class Provider {
        public static void main(String[] args) throws Exception {
            ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"provider.xml"});
            context.start();
            System.in.read();
        }
    }
  2. Run the Provider main method to start the service.

Verify the provider

Log on to the Nacos console at http://127.0.0.1:8848. In the left navigation pane, click Service List.

The service com.alibaba.edas.IHelloService appears in the list, along with its Service Group and Provider IP.

Step 2: Create a consumer

Create a separate Maven project for the consumer, subscribe to the provider service, and verify the call works locally.

2.1 Create a Maven project and add dependencies

Follow the same steps as Step 1.1 to create a Maven project and add the same three dependencies to pom.xml.

2.2 Define the service interface

  1. In src/main/java, create the package com.alibaba.edas.

  2. In com.alibaba.edas, create the same IHelloService interface:

    package com.alibaba.edas;
    
    public interface IHelloService {
        String sayHello(String str);
    }
In production, define the interface in a shared module and reference it from both the provider and consumer via Maven dependencies. Duplicating the interface here is for demonstration only.

2.3 Configure the Dubbo service

  1. In src/main/resources, create consumer.xml.

  2. Add the Spring and Dubbo XML namespaces (same as provider.xml):

    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
    xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
    http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
  3. Subscribe to the provider service:

    <dubbo:application name="demo-consumer"/>
    
    <dubbo:registry address="nacos://127.0.0.1:8848"/>
    
    <dubbo:reference id="helloService" interface="com.alibaba.edas.IHelloService"/>

2.4 Start the consumer

  1. In com.alibaba.edas, create the Consumer class:

    package com.alibaba.edas;
    
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import java.util.concurrent.TimeUnit;
    
    public class Consumer {
        public static void main(String[] args) throws Exception {
            ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"consumer.xml"});
            context.start();
            while (true) {
                try {
                    TimeUnit.SECONDS.sleep(5);
                    IHelloService demoService = (IHelloService)context.getBean("helloService");
                    String result = demoService.sayHello("world");
                    System.out.println(result);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
  2. Run the Consumer main method to start the service.

Verify the consumer

After startup, the console continuously prints:

hello world

This output confirms the consumer is successfully calling the provider.

Log on to the Nacos console at http://127.0.0.1:8848 and click Services in the left navigation pane. Select Callers.

The service com.alibaba.edas.IHelloService appears in the list, along with its Service Group and Subscriber IP.

Step 3: Deploy to SAE

Package the provider and consumer as executable JAR files, then deploy them to SAE.

3.1 Add the build plugin

Add the following <build> configuration to the pom.xml of each project:

  • Provider — set mainClass to com.alibaba.sae.Provider:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <classifier>spring-boot</classifier>
                            <mainClass>com.alibaba.sae.Provider</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
  • Consumer — set mainClass to com.alibaba.sae.Consumer:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <classifier>spring-boot</classifier>
                            <mainClass>com.alibaba.sae.Consumer</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

3.2 Build the JAR packages

In each project directory, run:

mvn clean package

This produces an executable JAR in the target/ directory.

3.3 Deploy to SAE

Deploy both JAR packages to SAE. For deployment steps, see Deploy a Java application.

After deployment, SAE automatically replaces the local Nacos registry address (nacos://127.0.0.1:8848) with the address of the SAE-managed service registry. No changes to your configuration files are needed.

What's next