FailedAnalyzer 自定义实现
创新互联 - 达州电信机房,四川服务器租用,成都服务器租用,四川网通托管,绵阳服务器托管,德阳服务器托管,遂宁服务器托管,绵阳服务器托管,四川云主机,成都云主机,西南云主机,达州电信机房,西南服务器托管,四川/成都大带宽,大带宽服务器,四川老牌IDC服务商
import org.springframework.boot.diagnostics.FailureAnalysis;
import org.springframework.boot.diagnostics.FailureAnalyzer;
/**
* Created by JavaDeveloperZone on 03-05-2018.
* Here we have implements FailureAnalyzer and override analyze method which will be
* called automatically when application startup will get failed.
*/
public class CustomFailedAnalyzer implements FailureAnalyzer {
@Override
public FailureAnalysis analyze(Throwable failure) {
return new FailureAnalysis("Custom Failed Message : ",failure.getMessage(),failure);
}
}
spring.factories文件配置
org.springframework.boot.diagnostics.FailureAnalyzer=com.javadeveloperzone.CustomFailedAnalyzer
注意:必须放置在resources/META-INF
原文地址:https://javadeveloperzone.com/spring-boot/spring-boot-startup-failure-analyzer-example/