Skip to content

Spring Boot FailureAnalyzer

FailureAnalyzer is a diagnostic tool in Spring Boot used to intercept and analyze application startup exceptions.^[600-developer__spring__springboot.md]

Purpose

The primary function of a FailureAnalyzer is to analyze startup errors.^[600-developer__spring__springboot.md] By intercepting exceptions that occur during the boot process, it can provide more readable or actionable error information to the developer instead of a raw stack trace.

Registration

To register a custom FailureAnalyzer, you must add the fully qualified class name of your implementation to the META-INF/spring.factories file under the key org.springframework.boot.diagnostics.FailureAnalyzer.^[600-developer__spring__springboot.md]

Configuration Access

If the analyzer requires access to the application context or configuration, the implementation class can implement specific Spring Aware Interfaces:

  • BeanFactoryAware: Implement this interface if the analyzer needs access to the BeanFactory.^[600-developer__spring__springboot.md]
  • EnvironmentAware: Implement this interface if the analyzer needs access to the Environment.^[600-developer__spring__springboot.md]

Sources

^[600-developer__spring__springboot.md]