An Aspire integration for hosting Java apps using either the Java executable or container image.
$ dotnet add package CommunityToolkit.Aspire.Hosting.JavaProvides extensions methods and resource definitions for the Aspire AppHost to support running Java/Spring applications either using either the JDK or a container and configuring the OpenTelemetry agent for Java.
In your AppHost project, install the package using the following command:
dotnet add package CommunityToolkit.Aspire.Hosting.Java
Then, in the Program.cs file of AppHost, define a Java resource, then call AddJavaApp or AddSpringApp:
// Define the Java container app resource
var containerapp = builder.AddSpringApp("containerapp",
new JavaAppContainerResourceOptions()
{
ContainerImageName = "<repository>/<image>",
OtelAgentPath = "<agent-path>"
});
// Define the Java executable app resource
var executableapp = builder.AddSpringApp("executableapp",
new JavaAppExecutableResourceOptions()
{
ApplicationName = "target/app.jar",
OtelAgentPath = "../../../agents"
});
https://learn.microsoft.com/dotnet/aspire/community-toolkit/hosting-java