Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to enable the health endpoint in Spring Boot.
Spring Boot
@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.[1](args); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'launch' instead of 'run' causes errors.
✗ Incorrect
The SpringApplication.run method starts the Spring Boot application.
2fill in blank
mediumComplete the code to expose the health endpoint in application.properties.
Spring Boot
management.endpoint.health.[1]=true Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'expose' or 'show' instead of 'enabled' will not work.
✗ Incorrect
The property 'management.endpoint.health.enabled' enables the health endpoint.
3fill in blank
hardFix the error in this custom health indicator class by completing the missing annotation.
Spring Boot
import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.stereotype.[1]; @[1] public class CustomHealthIndicator implements HealthIndicator { @Override public Health health() { return Health.up().withDetail("status", "All systems go").build(); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Service or @Controller will not register the health indicator correctly.
✗ Incorrect
The @Component annotation registers the class as a Spring bean so it can be used as a health indicator.
4fill in blank
hardFill both blanks to customize the health endpoint path and enable detailed health info.
Spring Boot
management.endpoints.web.path-mapping.health=[1] management.endpoint.health.show-details=[2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '/healthcheck' for the path but 'never' for details hides info unintentionally.
✗ Incorrect
Setting the path mapping changes the health endpoint URL, and 'always' shows detailed health info.
5fill in blank
hardFill all three blanks to create a custom health indicator that reports DOWN status with a message.
Spring Boot
import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.stereotype.Component; @Component public class CustomDownHealthIndicator implements HealthIndicator { @Override public Health health() { return Health.[1]().withDetail("[2]", "[3]").build(); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Health.up() instead of Health.down() gives wrong status.
✗ Incorrect
Health.down() sets the status to DOWN, with a detail key 'error' and a message explaining the problem.