手寫一個springboot錯誤自動通知starter外掛
手寫一個springboot錯誤自動通知starter外掛
緣起
在實際工作當中, 每次線上問題到達開發時間久,線上日誌查詢問題麻煩,所以想在程式發生錯誤時直接監聽到並將錯誤資訊傳送給開發同學,提高客戶使用體驗
資源
https://github.com/lihang1991/exception-spring-boot-starter
使用
該jar正在申請釋出到中央倉庫(地址待完善)
- maven引用
<dependency> <groupId>com.github.lihang1991</groupId> <artifactId>exception-spring-boot-starter</artifactId> <version>1.0.0</version> </dependency>
- 配置
exception-handle: project-name: com.lihang.exception.client ## 工程名稱 email: from: [email protected] # 傳送郵箱 to: - [email protected] # 傳送到(支援list) cc: - [email protected] # 抄送(支援list) spring: mail: host: smtp.163.com port: 25 password: ceshi123456 username: [email protected]
@SpringBootApplication // 切面 @EnableExceptionHandle(value = "execution(* com.lihang.exception.client.controller.*.*(..))") public class ExceptionCilentApplication { public static void main(String[] args) { SpringApplication.run(ExceptionCilentApplication.class, args); } }
結果展示