0
0
Spring Bootframework~30 mins

Info endpoint configuration in Spring Boot - Mini Project: Build & Apply

Choose your learning style9 modes available
Info endpoint configuration
📖 Scenario: You are building a Spring Boot application that needs to expose custom information about the app through the /actuator/info endpoint.This is useful for showing app version, description, or other metadata in a standardized way.
🎯 Goal: Configure the Spring Boot info endpoint to expose custom application information using properties and Java configuration.
📋 What You'll Learn
Create a properties file with custom info entries
Enable the info endpoint in Spring Boot
Create a configuration class to add additional info programmatically
Verify the info endpoint exposes all configured information
💡 Why This Matters
🌍 Real World
Exposing application metadata helps operations teams monitor app versions and build details easily.
💼 Career
Configuring actuator info endpoints is a common task for backend developers working with Spring Boot microservices.
Progress0 / 4 steps
1
Create application.properties with custom info entries
Create a file named application.properties and add these exact entries:
info.app.name=MyApp
info.app.description=This is a sample Spring Boot app
info.app.version=1.0.0
Spring Boot
Need a hint?

Properties starting with info. are automatically exposed by Spring Boot's info endpoint.

2
Enable the info endpoint in application.properties
Add this exact line to application.properties to enable the info endpoint:
management.endpoint.info.enabled=true
Spring Boot
Need a hint?

Spring Boot actuator endpoints are disabled by default; you must enable the info endpoint explicitly.

3
Create a configuration class to add custom info programmatically
Create a Java class named CustomInfoConfig annotated with @Configuration.
Inside it, create a method customInfoContributor annotated with @Bean that returns an InfoContributor.
Inside the method, return a lambda that adds an info entry with key build.time and value "2024-06-01T12:00:00Z" using builder.withDetail.
Spring Boot
Need a hint?

The InfoContributor interface allows adding custom info entries programmatically.

4
Expose the info endpoint by adding actuator dependency and verify
Ensure your project has the Spring Boot Actuator dependency added.
In your main application class, add @SpringBootApplication annotation.
Run the app and verify the /actuator/info endpoint shows app.name, app.description, app.version, and build.time entries.
Spring Boot
Need a hint?

The main class must have a main method to run the Spring Boot app.

Verify the info endpoint by visiting http://localhost:8080/actuator/info in your browser.