Bird
0
0

You want to create a custom actuator endpoint that returns a map of application info with keys "version" and "status". Which code snippet correctly implements this?

hard📝 component behavior Q8 of 15
Spring Boot - Actuator
You want to create a custom actuator endpoint that returns a map of application info with keys "version" and "status". Which code snippet correctly implements this?
A@Component @Endpoint(id = "appinfo") public class AppInfoEndpoint { @ReadOperation public Map<String, String> info() { return Map.of("version", "1.0", "status", "running"); } }
B@Component @Endpoint(id = "appinfo") public class AppInfoEndpoint { public Map<String, String> info() { return Map.of("version", "1.0", "status", "running"); } }
C@Endpoint(id = "appinfo") public class AppInfoEndpoint { @ReadOperation public String info() { return "version:1.0, status:running"; } }
D@Component @RestController public class AppInfoEndpoint { @GetMapping("/actuator/appinfo") public Map<String, String> info() { return Map.of("version", "1.0", "status", "running"); } }
Step-by-Step Solution
Solution:
  1. Step 1: Check annotations for custom actuator endpoint

    Use @Component and @Endpoint(id=...) to define the endpoint bean.
  2. Step 2: Ensure method is exposed

    Method must have @ReadOperation and return Map for key-value info.
  3. Final Answer:

    Option A correctly defines the endpoint with proper annotations and return type -> Option A
  4. Quick Check:

    Custom endpoint with map data = @Component + @Endpoint + @ReadOperation [OK]
Quick Trick: Use @ReadOperation and return Map for key-value actuator data [OK]
Common Mistakes:
  • Omitting @ReadOperation on method
  • Using @RestController instead of @Endpoint
  • Returning String instead of Map for structured data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes