> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ale.run/llms.txt
> Use this file to discover all available pages before exploring further.

# Spring Boot (JVM)

> Guide for Spring Boot applications written in Java/Kotlin.

***

## Prerequisites

<AccordionGroup>
  <Accordion title="Supported JDK Versions">
    | Spring Boot Version | Supported JDK Version |
    | ------------------- | --------------------- |
    | Spring Boot 3.x     | JDK 17 or higher      |
    | Spring Boot 2.x     | JDK 8 or higher       |
  </Accordion>
</AccordionGroup>

<Warning>
  Ensure that the JDK version specified in your project configuration files (e.g., pom.xml, build.gradle) matches the version selected during deployment. A mismatch may cause build errors.
</Warning>

<Tip>
  By default, JAR artifacts and scripts are supported. For WAR files, only Executable WAR is supported.
</Tip>

## Select Template and Repository

<Frame>
  <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/developers/images/en/springboot_02.png" />
</Frame>

> On the dashboard, click <Icon icon="circle-plus" iconType="solid" size={15} color="2396F1" /> or `⌘ + K` to open the deployment modal and select the Java template. Then choose a GitHub repository from the dropdown or [input a Git repository URL in the Git URL tab](/en/developers/private-repo).

## Deployment Settings

> Apply the following settings to ensure your service runs seamlessly.

<AccordionGroup>
  <Accordion title="Basic Settings">
    * **Version**
    * [Environment Variables](/en/developers/env)
    * [Port Number](/en/developers/port)
    * **Start Command**
    * [Health Check](/en/developers/zero-downtime-deployment)
  </Accordion>

  <Accordion title="More Options">
    * **Build Variables**: Variables to include during container image builds
    * **Embedded Node.js**: Node.js version required for builds within the project
    * **Pre-built jar file path**: Path to a pre-built jar file already present in the repository
    * **Build Command**: Gradle/Maven build command
    * **Include files in build**: Files or directories to include during the build
    * **Update strategy**
      * **Rolling Update**: Deploy new version incrementally while maintaining service availability. Requires sufficient node resources
      * **Recreate**: Stop all instances before deploying new version. Results in downtime
  </Accordion>
</AccordionGroup>

## Set Resources and Deploy

<Frame>
  <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/developers/images/en/08_04.png" />
</Frame>

* **Resource Type**: Select between [On-demand or Spot instance types](/en/developers/resource#on-demand-spot)

* **CPU**: Maximum vCPU resource for the service. Minimum vCPU means 0.1 vCPU

* **Memory**: Maximum memory size your service can use

* [Replica](/en/developers/replica): Number of service replicas for high availability and load balancing

* **Deploy**: Click `Deploy`

<Info>
  Once deployment is complete, you can access the web page via the preview domain or send requests using an API tool.
</Info>

<Tip>
  If deployment fails due to resource limitations, see [the Space and Resource Management page](/en/operations/spaces#allocate-resources) to add resources to your space.
</Tip>

## Advanced Settings

### Deploy Jar Files from the Repository

* When deploying a Spring Boot jar file reflected in the repository, specify the jar file path in the **Pre-built jar file path** field of the deployment settings, as per your build tool:
  * **Gradle**: `build/libs/[project-name].jar`
  * **Maven**: `target/[project-name].jar`

### Include Specific Resource Paths in the Build Process

* When deploying a Spring Boot project via `ale`, files in the `src` directory, except for those defined in `WebProperties.Resources` (e.g., `/static`), are excluded from the build.<br />
  If your project references resources from specific paths, include those directories in the **Include files in build** field of the deployment settings. Use commas (`,`) to specify multiple directories.

### Deploy Multi-Module Applications

* Deploying a Spring Boot application composed of multiple modules requires specific configurations. The following example outlines the process:

  ```plain theme={null}
  project-root/
    ├── build.gradle.kts
    ├── settings.gradle.kts
    ├── api/
    │   ├── build.gradle.kts
    │   └── src/
    │       └── main/
    │           ├── kotlin/
    │           └── resources/
    ├── core/
    │   ├── build.gradle.kts
    │   └── src/
    │       └── main/
    │           ├── kotlin/
    │           └── resources/
    └── gradle/
        └── wrapper/
            ├── gradle-wrapper.jar
            └── gradle-wrapper.properties
  ```

  * Configure the `api` module as the main class and structure as shown.

  <Figure className="mt-5 mb-4" src="https://files.cloudtype.io/ale-docs/quickstart/springboot/deployment-3.png" size="3xl" />

  <Figure className="mt-5 mb-12" src="https://files.cloudtype.io/ale-docs/quickstart/springboot/deployment-4.png" size="3xl" />

  * After selecting the Spring Boot template, apply the following settings:
    * **Start Command**: `java -jar api/build/libs/api-0.0.1-SNAPSHOT.jar`
      * Replace `<main-module-name>` with the actual module name.
    * **Include files in build**: `core,api`
      * Separate module directory names with commas.

***

[Spring Boot Docs](https://docs.spring.io/spring-boot/docs/current/reference/html/index.html)
