Bird
0
0

How can you programmatically add custom info data to the info endpoint in a Spring Boot application?

hard📝 Application Q9 of 15
Spring Boot - Actuator
How can you programmatically add custom info data to the info endpoint in a Spring Boot application?
AUse <code>@InfoData</code> annotation on a configuration class
BAdd properties under <code>management.info.custom</code> in application.properties
CImplement a bean of type <code>InfoContributor</code> and override its contribute method
DCreate a REST controller mapped to /actuator/info
Step-by-Step Solution
Solution:
  1. Step 1: Identify programmatic extension method

    Spring Boot allows adding info data by implementing InfoContributor bean.
  2. Step 2: Differentiate from property and annotation approaches

    Properties add static data; no @InfoData annotation exists; REST controller is not recommended.
  3. Final Answer:

    Implement InfoContributor bean and override contribute() -> Option C
  4. Quick Check:

    Programmatic info data = InfoContributor bean [OK]
Quick Trick: Use InfoContributor bean to add dynamic info data [OK]
Common Mistakes:
  • Trying to use non-existent annotations
  • Adding custom REST controllers for info
  • Misusing property keys for dynamic data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes