千家信息网

spring boot之FailureAnalyzer

发表于:2024-12-12 作者:千家信息网编辑
千家信息网最后更新 2024年12月12日,FailedAnalyzer 自定义实现import org.springframework.boot.diagnostics.FailureAnalysis;import org.springfra
千家信息网最后更新 2024年12月12日spring boot之FailureAnalyzer

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/

0