--- title: "Spring Boot" url: https://docs.catalyst.zoho.com/en/serverless/help/appsail/help-guides/java/spring-boot/ description: "Catalyst AppSail is a fully-managed PaaS component of Catalyst Serverless that enables you to develop and deploy services in Java, Node.js, and Python in the cloud with ease, and manage your platform instances." last_updated: 2025-11-03T10:48:29Z service: Serverless type: general --- # Spring Boot [Spring Boot](https://spring.io/projects/spring-boot) is built on top of the popular [Spring framework](https://spring.io), and includes a wide range of enhancements that allow you to easily build production-grade microservices, web applications, and standalone Spring projects with reduced development efforts. Spring Boot typically includes embedded HTTP servers like Jetty or Apache Tomcat, without the complex XML configurations of Spring. > **Note:** When you export a Spring Boot app as a JAR file in the example below, you can retain the embedded server included in it. However, when you export the Spring Boot app as a WAR file, you will need to exclude the embedded server included in it, if you initialize it as Java WAR in AppSail. This is because AppSail offers native support for WAR files and bundles them with the Jetty server by default. ### Spring Boot- JAR This example illustrates the steps to build a sample Spring Boot app, export it as a JAR file, and deploy it to AppSail. 1. Open [Spring Initializr](https://start.spring.io/) to create a new project. 2. Choose the following configurations for your project: a. Project - Maven Project b. Language - Java c. Spring Boot Version - 2.7.10 d. Package - JAR e. Java Version - 8 f. Click **Add Dependencies** and select **Spring Web**. 3. Click **Generate**. 4. Unzip the project and open it in any IDE of your choice. 5. Add necessary controllers to the project. For example, create a file named `DemoController.java` in the main Java file's directory of your project, and add the controller specified below in the file. ```java package com.example.demo; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class DemoController { @GetMapping("/") public String index() { return "Greetings from Spring Boot!"; } } ``` 6. Catalyst will check the [port configured for listening](https://docs.catalyst.zoho.com/en/serverless/help/appsail/key-concepts/appsail-execution/#default-port-for-app-startups) with the environment variable `X_ZOHO_CATALYST_LISTEN_PORT` and the app must listen to that port on all interfaces (host 0.0.0.0). Therefore, you will need to customize the port. You can do this by creating a file named `ServerPortCustomizer.java` in the main Java file's directory of your project, and adding the code specified below in it: ```java package com.example.demo; import org.springframework.boot.web.server.ConfigurableWebServerFactory; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.stereotype.Component; @Component public class ServerPortCustomizer implements WebServerFactoryCustomizer { @Override public void customize(ConfigurableWebServerFactory factory) { String port = System.getenv("X_ZOHO_CATALYST_LISTEN_PORT"); int listenPort; if(port != null && !port.isEmpty()) { listenPort = Integer.parseInt(System.getenv("X_ZOHO_CATALYST_LISTEN_PORT")); } else { listenPort = 9000; } factory.setPort(listenPort); } } ``` You can now save the application and run it in Catalyst. 7. You can run this application on your local machine by executing the following command from your terminal: ```java ./mvnw spring-boot:run ``` 8. You can then compile the source code, run tests, and package the compiled code by executing the following command: ```java ./mvnw clean package ``` This will generate the JAR file of the application in the target folder. 9. You can now [initialize an AppSail service](https://docs.catalyst.zoho.com/en/cli/v1/initialize-resources/initialize-appsail/) in the same directory from the CLI or [add it](https://docs.catalyst.zoho.com/en/cli/v1/add-appsail/) in an existing project directory. The app's source must be your application's directory. Provide the following values while initializing the app service: **Stack:** Java 8 **Platform:** Java SE 10. Ensure the JAR file is added in the build directory you specified during initialization. Catalyst will automatically ZIP your app file during deployment to the remote console. 11. [Deploy the app service](https://docs.catalyst.zoho.com/en/cli/v1/deploy-resources/deploy-appsail//) to the console. 12. You can then configure the [startup command](https://docs.catalyst.zoho.com/en/serverless/help/appsail/key-concepts/appsail-execution/#startup-commands) given below from the console: ```java java -jar demo-0.0.1-SNAPSHOT.jar ``` You can also configure this in the `app-config.json` file before deploying. Access the deployed app service from its [endpoint URL](https://docs.catalyst.zoho.com/en/serverless/help/appsail/key-concepts/appsail-execution/#custom-domain-url). ### Spring Boot - WAR This example explains the steps to build a sample Spring Boot app, export it as a WAR file, and deploy it to AppSail: 1. Open [Spring Initializr](https://start.spring.io/) to create a new project. 2. Choose the following configurations for your project: a. Project - Maven Project b. Language - Java c. Spring Boot Version - 2.7.10 d. Package - WAR e. Java Version - 8 f. Click **Add Dependencies** and select **Spring Web**. 3. Click **Generate**. 4. Unzip the project and open in any IDE of your choice. 5. You must now add necessary controllers to the project. For example, create a file named `DemoController.java` in the main Java file's directory of your project, and add the controller specified below in the file. ```java package com.example.demo; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class DemoController { @GetMapping("/") public String index() { return "Greetings from Spring Boot WAR!"; } } ``` 6. You must now modify the `pom.xml` file in your project to exclude the embedded Tomcat server while generating the WAR file, as explained in the overview. You can do this by adding the snippet given below in the `spring-boot-maven-plugin enclosure` in the XML file: ```json <configuration> <mainClass>${main_class_name}</mainClass> <classifier>exec</classifier> </configuration> ``` 7. You can run this application on your local machine by executing the following command from your terminal: ```java ./mvnw spring-boot:run ``` 8. You can upload the application to Catalyst with this command: ```java ./mvnw clean package ``` This will generate the WAR file of the application in the target folder. 9. You can now [initialize an AppSail service](https://docs.catalyst.zoho.com/en/cli/v1/initialize-resources/initialize-appsail/) in the same directory from the CLI or [add it](https://docs.catalyst.zoho.com/en/cli/v1/add-appsail/) in an existing project directory. The app's source must be your application's directory. Provide the following values while initializing the app service: **Stack:** Java 8 **Platform:** Java WAR 10. Ensure the WAR file is added in the build directory you specify during initialization. Catalyst will automatically ZIP your app file during deployment to the remote console. 11. [Deploy the app service](https://docs.catalyst.zoho.com/en/cli/v1/deploy-resources/deploy-appsail//) to the console. Access the deployed app service from its [endpoint URL](https://docs.catalyst.zoho.com/en/serverless/help/appsail/key-concepts/appsail-execution/#custom-domain-url).