This topic describes how to deploy a Spring Boot application to Function Compute. Function Compute provides a method different from traditional deployment methods. You can deploy a traditional Spring Boot application to Function Compute and use the application for production without performing operations such as purchasing a server. The deployed Spring Boot application can use the auto scaling, pay-as-you-go, and O&M-free features of Function Compute.


The following operations are complete:

Background information

Spring Boot is a new open source and lightweight framework developed by the Pivotal team in 2013 and released in April 2014. Spring Boot is designed based on Spring 4.0. Spring Boot inherits the original excellent features of the Spring framework, and simplifies the entire construction and development process of Spring applications by simplifying configurations. In addition, Spring Boot resolves problems such as version conflicts and reference instability of dependent packages by integrating a large number of frameworks.


  1. Run the following command in the specified directory to initialize a project:
    s init devsapp/start-springboot -d start-springboot
    The -d parameter specifies the project name. In this example, the project name is start-springboot.
    Note Skip this step if the item exists.
    Sample command output:
     Serverless Awesome:
     devsapp! file decompression completed
     please select credential alias default
         _____            _            ______             _
        /  ___|          (_)           | ___ \           | |
        \ `--. _ __  _ __ _ _ __   __ _| |_/ / ___   ___ | |_
         `--. \ '_ \| '__| | '_ \ / _` | ___ \/ _ \ / _ \| __|
        /\__/ / |_) | |  | | | | | (_| | |_/ / (_) | (_) | |_
        \____/| .__/|_|  |_|_| |_|\__, \____/ \___/ \___/ \__|
              | |                  __/ |
              |_|                 |___/
        Welcome to the start-springboot application
         This application requires to open these services:
             FC :
         This application can help you quickly deploy the SpringBoot project:
             Full yaml configuration    :
             SpringBoot development docs:
         This application homepage:
     Thanks for using Serverless-Devs
     You could [cd /test/start-springboot] and enjoy your serverless journey!
     If you need help for this example, you can use [s -h] after you enter folder.
     Document Star:
  2. Run the following command to go to the project directory:
    cd start-springboot
  3. Run the following command to deploy the project:
    s deploy
    Sample command output:
    [2021-09-01T14:15:08.995] [INFO ] [S-CLI] - Start ...
     Using web framework type: nas, If you want to deploy with container, you can [s cli fc-default set web-framework container] to switch.
    [2021-09-01T14:15:10.352] [INFO ] [WEB-FRAMEWORK] - The configuration of the domain name is not detected, and a temporary domain name is generated.
    (node:45614) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
      End of request
      End of request
    [2021-09-01T14:15:14.711] [INFO ] [FC-DEPLOY] - Using region: cn-hangzhou
    [2021-09-01T14:15:14.712] [INFO ] [FC-DEPLOY] - Using access alias: default
    [2021-09-01T14:15:14.712] [INFO ] [FC-DEPLOY] - Using accessKeyID: 188077086902****
    [2021-09-01T14:15:14.712] [INFO ] [FC-DEPLOY] - Using accessKeySecret: KdcUEJLoGto****
      Using fc deploy type: sdk, If you want to deploy with pulumi, you can [s cli fc-default set deploy-type pulumi] to switch.
    [2021-09-01T14:15:14.944] [INFO ] [FC-DEPLOY] - Checking Service web-springboot exists
    [2021-09-01T14:15:15.417] [INFO ] [FC-DEPLOY] - Setting role: AliyunFCDefaultRole
    [2021-09-01T14:15:15.480] [INFO ] [RAM] - Checking Role AliyunFCDefaultRole exists
    [2021-09-01T14:15:15.763] [INFO ] [RAM] - Updating role: AliyunFCDefaultRole
    [2021-09-01T14:15:15.940] [INFO ] [RAM] - Checking Plicy AliyunFCDefaultRolePolicy exists
    [2021-09-01T14:15:16.426] [INFO ] [FC-DEPLOY] - Using logConfig: auto: fc will try to generate default sls project
    [2021-09-01T14:15:16.636] [INFO ] [SLS] - Checking Project 188077086902****-cn-hangzhou-logproject exists
    [2021-09-01T14:15:16.954] [INFO ] [SLS] - Checking Logstore 188077086902****-cn-hangzhou-logproject/fc-service-web-springboot-logstore exists
    [2021-09-01T14:15:18.988] [INFO ] [SLS] - Checking Logstore index 188077086902****-cn-hangzhou-logproject/fc-service-web-springboot-logstore exists
      Using fc deploy type: sdk, If you want to deploy with pulumi, you can [s cli fc-default set deploy-type pulumi] to switch.
    [2021-09-01T14:15:19.024] [INFO ] [FC-DEPLOY] - Generated logConfig:
    enableInstanceMetrics: true
    enableRequestMetrics: true
    logstore: fc-service-web-springboot-logstore
    project: 188077086902****-cn-hangzhou-logproject
    [2021-09-01T14:15:19.025] [INFO ] [FC-DEPLOY] - Using vpcConfig: auto: fc will try to generate related vpc resources automatically
    [2021-09-01T14:15:19.504] [INFO ] [VPC] - Getting vpc: fc-deploy-component-generated-vpc-cn-hangzhou
    [2021-09-01T14:15:19.605] [INFO ] [VPC] - Getting vswitch: fc-deploy-component-generated-vswitch-cn-hangzhou
    [2021-09-01T14:15:19.696] [INFO ] [VPC] - Getting securityGroup: fc-deploy-component-generated-securityGroup-cn-hangzhou
    [2021-09-01T14:15:19.770] [INFO ] [FC-DEPLOY] - Generated vpcConfig:
    securityGroupId: sg-bp117ue6hnozayz6****
    vSwitchId: vsw-bp167nedaxg0avapv****
    vpcId: vpc-bp1j70bzw9k4snkgq****
    [2021-09-01T14:15:19.771] [INFO ] [FC-DEPLOY] - Using nasConfig: auto: fc will try to generate related nas file system automatically
    [2021-09-01T14:15:30.414] [INFO ] [FC-DEPLOY] - Generated nasConfig:
    groupId: 10003
      - fcDir: /mnt/auto
        nasDir: /web-springboot
    userId: 10003
    [2021-09-01T14:15:30.418] [INFO ] [FC-DEPLOY] - Checking Function springboot exists
    [2021-09-01T14:15:30.462] [WARN ] [FC-DEPLOY] - Image dose not exist locally.
    Maybe you need to run 's build' first if it dose not exist remotely.
    [2021-09-01T14:15:30.466] [INFO ] [FC-DEPLOY] - Checking Trigger web-springboot exists
    [2021-09-01T14:15:30.506] [INFO ] [FC-DEPLOY] - Checking Trigger web-springboot exists
    [2021-09-01T14:15:30.571] [INFO ] [FC-DEPLOY] - Creating service: web-springboot
    [2021-09-01T14:15:30.571] [INFO ] [FC-DEPLOY] - Creating function: springboot
    [2021-09-01T14:15:30.571] [INFO ] [FC-DEPLOY] - Creating triggers: ["web-springboot"]
      Make service web-springboot success.
      Make function web-springboot/springboot success.
      Make trigger web-springboot/springboot/web-springboot success.
    [2021-09-01T14:15:32.366] [INFO ] [FC-DEPLOY] - Checking Service web-springboot exists
    [2021-09-01T14:15:32.408] [INFO ] [FC-DEPLOY] - Checking Function springboot exists
    [2021-09-01T14:15:32.463] [INFO ] [FC-DEPLOY] - Checking Trigger web-springboot exists
    [2021-09-01T14:15:32.571] [INFO ] [FC-DEPLOY] - Creating custom domain: springboot.web-springboot.188077086902**** file decompression completed
    [2021-09-01T14:15:33.223] [INFO ] [FC-DOMAIN] - Creating custom domain: springboot.web-springboot.188077086902****
    There is auto config in the service: web-springboot
    [2021-09-01T14:15:33.943] [INFO ] [WEB-FRAMEWORK] - nas component get src is: ./code/target/demo-0.0.1-SNAPSHOT.jar
     Start uploading file: /mnt/0af104930d-ljj61-cn-hangzhou/web-springboot/springboot
      File uploaded successfully: /mnt/0af104930d-ljj61-cn-hangzhou/web-springboot/springboot
      upload done
      Try container acceleration
      region: cn-hangzhou
      serviceName: web-springboot
      functionName: springboot
        - >-


After the project is deployed, you can view the temporary domain name generated by Function Compute in the execution output. The temporary domain name can be used to access the newly deployed application. For example, run the following command to access the application:

curl http://springboot.web-springboot.188077086902****
Note The temporary domain name is used only for demonstration and development purposes. It is valid for a limited period of time. You must use a domain name that has obtained an Internet Content Provider (ICP) filing from Alibaba Cloud for production. For more information, see Configure a custom domain name.