# AddSpringBootApp

- Module: [Aspire.Hosting.Java](/reference/api/go/aspire.hosting.java.md)
- Version: `17.0.0-preview.1.26565.2`
- Kind: `method`
- Defined on: `DistributedApplicationBuilder`
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Adds a Spring Boot application to the application model, built and launched with its own Maven or Gradle wrapper.

## Remarks

This is `AddJavaApp` with the common
Spring Boot configuration already applied: the build tool is detected when the resource starts, the
application is launched through that tool's Spring Boot plugin (`spring-boot:run` or `bootRun`),
and an HTTP endpoint is declared through `SERVER_PORT`, which is the environment
variable Spring Boot reads for its listening port. Everything else is the same, so any `With...` method
that works on `AddJavaApp` works here too.
The launch goal compiles the application itself, so Aspire does not add a separate build resource before
it. Publishing still packages the application with tests skipped (`-DskipTests` for Maven,
`-x test` for Gradle). Call `WithMavenBuild` or
`WithGradleBuild` afterwards to customize those package arguments.
The one thing that does add a build resource is
`WithOtelAgent` with a build-produced agent, which cannot be
loaded until a build has written it.
No health check is added. `/actuator/health` only exists when the application depends on
`spring-boot-starter-actuator`, and adding it unconditionally would leave applications without that
dependency permanently unhealthy and silently stall every `WaitFor` on them. Add
`WithHttpHealthCheck("/actuator/health")` when the actuator is present.

## Definition

```go
func (DistributedApplicationBuilder) AddSpringBootApp(
    name string,
    appDirectory string,
) JavaAppResource
```

## Parameters

- `name` (`string`) -- The name of the resource.
- `appDirectory` (`string`) -- The application directory, containing `pom.xml`, `build.gradle`, `build.gradle.kts`, `settings.gradle`, or `settings.gradle.kts`. Relative paths are resolved against the AppHost directory.

## Returns

[`JavaAppResource`](/reference/api/go/aspire.hosting.java/javaappresource.md) -- A reference to the `IResourceBuilder`.

Returns a handle; failures surface later via `Err()`.

## Applies to

- `DistributedApplicationBuilder`
