This topic for developers tells you how to configure a Spring Boot app for observation by Application Live View within Tanzu Application Platform (commonly known as TAP).
For Application Live View to interact with a Spring Boot app within Tanzu Application Platform,
add the spring-boot-starter-actuator
module dependency.
Add the maven dependency in pom.xml
as follows:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Add the following plugin configuration in pom.xml
:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
<configuration>
<additionalProperties>
<spring.boot.version>${project.parent.version}</spring.boot.version>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
Add the preceding configuration to generate build-info.properties
into your Spring Boot application.
This information is then used to display the Spring Boot version that the app uses in Application Live View.
To enable Application Live View for Spring Boot apps, Spring Boot conventions automatically sets the Application Live View labels onto the PodSpec. For more information about the labels automatically set by Spring Boot conventions, see Enable Application Live View for Spring Boot applications.
For Application Live View to interact with a Spring Boot 3 app within Tanzu Application Platform,
add the spring-boot-starter-actuator
module dependency.
Add the maven dependency in pom.xml
as follows:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Add the following plugin configuration in pom.xml
:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
<configuration>
<additionalProperties>
<spring.boot.version>${project.parent.version}</spring.boot.version>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
Add the preceding configuration to generate build-info.properties
into your Spring Boot application.
This information is then used to display the Spring Boot version that the app uses in Application Live View.
To enable Application Live View for Spring Boot 3 apps, Spring Boot conventions automatically sets the Application Live View labels onto the PodSpec. For more information about the labels automatically set by Spring Boot conventions, see Enable Application Live View for Spring Boot applications.
Here is an example of creating a workload for a Spring Boot 3 Application:
tanzu apps workload create spring-boot-3 --git-repo https://github.com/martinlippert/sb3-demo.git --git-branch main --annotation autoscaling.knative.dev/min-scale=1 --yes --label app.kubernetes.io/part-of=tanzu-java-web-app --type web --build-env "BP_JVM_VERSION=17" --label apps.tanzu.vmware.com/auto-configure-actuators="true"
For Application Live View to interact with a Spring Cloud Gateway app within Tanzu Application Platform,
add the spring-boot-starter-actuator
and spring-cloud-starter-gateway
module dependency.
Add the maven dependencies in pom.xml
as follows:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
To enable Application Live View on the Spring Cloud Gateway Tanzu Application Platform workload, Spring Boot conventions automatically applies labels on the workload, such as tanzu.app.live.view.application.flavours: spring-boot_spring-cloud-gateway
and tanzu.app.live.view: true
, based on the Spring Cloud Gateway image metadata.
Here is an example of creating a workload for a Spring Cloud Gateway Application:
tanzu apps workload create tanzu-scg-web-app --git-repo https://github.com/ksankaranara-vmw/gs-gateway.git --git-branch main --type web --label app.kubernetes.io/part-of=tanzu-scg-web-app --yes --annotation autoscaling.knative.dev/min-scale=1
If your application image is NOT built with Tanzu Build Service, to enable Application Live View on Spring Boot
Tanzu Application Platform workload, use the following command. For example:
tanzu apps workload create boot-app --type web --app boot-app --image <IMAGE NAME> --annotation autoscaling.knative.dev/min-scale=1 --yes --label tanzu.app.live.view=true --label tanzu.app.live.view.application.name=boot-app --label tanzu.app.live.view.application.flavours=spring-boot
If your application image is NOT built with Tanzu Build Service, to enable Application Live View on Spring Cloud Gateway
Tanzu Application Platform workload, use the following command. For example:
tanzu apps workload create scg-app --type web --app scg-app --image <IMAGE NAME> --annotation autoscaling.knative.dev/min-scale=1 --yes --label tanzu.app.live.view=true --label tanzu.app.live.view.application.name=scg-app --label tanzu.app.live.view.application.flavours=spring-boot_spring-cloud-gateway
If your application image is NOT built with Tanzu Build Service, to enable Application Live View on Steeltoe
Tanzu Application Platform workload, use the following command. For example:
tanzu apps workload create steeltoe-app --type web --app steeltoe-app --image <IMAGE NAME> --annotation autoscaling.knative.dev/min-scale=1 --yes --label tanzu.app.live.view=true --label tanzu.app.live.view.application.name=steeltoe-app --label tanzu.app.live.view.application.flavours=steeltoe