Giriş
Custom Starter sınıflarda hata oluşursa, daha okunaklı bir çıktı alabilmeyi sağlar.
Örnek
Elimizde şöyle bir kod olsun
Şöyle yaparızimport org.springframework.boot.diagnostics.AbstractFailureAnalyzer;import org.springframework.boot.diagnostics.FailureAnalysis;public class InvalidGreeterSalutationFailureAnalyzer extends AbstractFailureAnalyzer {@Overrideprotected FailureAnalysis analyze(Throwable rootFailure, InvalidSalutationException cause) {return new FailureAnalysis(String.format("'%s' is an invalid salutation", cause.getSalutation()),"A valid salutation must begin with an upper-case letter",cause);}}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=
com.github.shazin.greeter.starter.config.GreeterServiceAutoConfigurationorg.springframework.boot.diagnostics.FailureAnalyzer=
com.github.shazin.greeter.starter.config.InvalidGreeterSalutationFailureAnalyzer
Hiç yorum yok:
Yorum Gönder