FailedAnalyzer 自定义实现
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/
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/197839.html