Deploy a Spring Boot App on Alibaba Cloud Function Compute in Minutes
This step‑by‑step guide shows how to enable Alibaba Cloud Function Compute, create a service and Java 17 function, configure a custom domain, export and edit the generated Spring Boot project, and adjust the listening port, enabling rapid serverless deployment for beginners.
What is Function Compute?
Alibaba Cloud Function Compute (FC) is an event‑driven, fully managed serverless platform that lets you run code without provisioning or managing servers. You only upload code, and FC automatically allocates resources, provides logging, monitoring, and pay‑per‑use billing.
Getting Started
Prerequisite: an Alibaba Cloud account with real‑name verification. Open the FC console at https://fcnext.console.aliyun.com and click “Enable” after accepting the service agreement.
Create a Service
In the console, go to “Service & Function”, click “Create Service”, fill the service name and configuration, optionally enable log and tracing, then confirm.
Create a Function
Select the newly created service, click “Create Function”, choose “Custom Runtime”, pick the Java 17 template, and configure the function. After filling the details, click “Create” to deploy a Spring Boot project.
Custom Domain Configuration
By default HTTP triggers return the response as an attachment. To serve normal web pages, add a custom domain in the domain management page, map the route to the service and function, and then access the domain to see the “Hello World!” output.
Exporting and Editing Code
You can develop directly in the online IDE or export the function code for local editing. The exported project contains a Maven pom.xml and a Spring Boot application class.
Project Structure
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1‑SNAPSHOT</version>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@GetMapping("/")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name);
}
}Configure Listening Port
Add the same port number to application.properties that you set for the function’s HTTP trigger, ensuring the function and the Spring Boot server listen on the same port.
Conclusion
The guide demonstrates that deploying a Spring Boot application with Function Compute is straightforward: a few clicks in the console generate and launch the service, making serverless Java development accessible to beginners without manual environment setup.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
