SpringBoot創建自定義FailureAnalyzer,啓動時攔截異常並轉換爲易讀消息。
MSCode微服務平臺框架 mscodecloud.com 代碼示例
FailureAnalyzer
實現註冊在 META-INF/spring.factories
.
org.springframework.boot.diagnostics.FailureAnalyzer=\
com.example.ProjectConstraintViolationFailureAnalyzer
MSCode微服務平臺框架 mscodecloud.com 是基於Spring Cloud、Spring Boot、Activiti7工作流和阿里巴巴組件,提供所有源碼和詳盡文檔的企業級快速開發平臺。