.NET Aspire Java/Spring hosting integration
Includes: Hosting integration not Client integration
Note
This integration is part of the .NET Aspire Community Toolkit and isn't officially supported by the .NET Aspire team.
In this article, you learn how to use the .NET Aspire Java/Spring hosting integration to host Java/Spring applications using either the Java runtime or a container.
Prerequisites
This integration requires the OpenTelemetry Agent for Java to be downloaded and placed in the agents
directory in the root of the project. Depending on your preferred shell, use either of the following commands to download the agent:
# bash/zsh
mkdir -p ./agents
wget -P ./agents \
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
Get started
To get started with the .NET Aspire Azure Static Web Apps emulator integration, install the 📦 CommunityToolkit.Aspire.Hosting.Java NuGet package in the AppHost project.
dotnet add package CommunityToolkit.Aspire.Hosting.Java
For more information, see dotnet add package or Manage package dependencies in .NET applications.
Example Usage
The following sections detail various example usage scenarios, from hosting a containerized Spring app to hosting an executable Spring app.
In the _Program.cs_file of your app host project, call the AddSpringApp
method to define the containerized Spring app. Use the JavaAppContainerResourceOptions
to define the containerized Spring app.
var containerapp = builder.AddSpringApp(
"containerapp",
new JavaAppContainerResourceOptions
{
ContainerImageName = "<repository>/<image>",
OtelAgentPath = "<agent-path>"
});
See also
.NET Aspire