0
0
Spring Bootframework~10 mins

Health endpoint customization in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Alaunch
Bstart
Crun
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'launch' instead of 'run' causes errors.
2fill in blank
medium

Complete 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'
Aenabled
Bshow
Cexpose
Dactivate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'expose' or 'show' instead of 'enabled' will not work.
3fill in blank
hard

Fix 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'
AService
BController
CRepository
DComponent
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Service or @Controller will not register the health indicator correctly.
4fill in blank
hard

Fill 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'
A/custom-health
Balways
Cnever
D/healthcheck
Attempts:
3 left
💡 Hint
Common Mistakes
Using '/healthcheck' for the path but 'never' for details hides info unintentionally.
5fill in blank
hard

Fill 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'
Adown
Berror
CDatabase connection failed
Dup
Attempts:
3 left
💡 Hint
Common Mistakes
Using Health.up() instead of Health.down() gives wrong status.