手写一个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: ceshi@163.com # 发送邮箱    to:      - ceshi@139.com # 发送到(支持list)    cc:      - ceshi@139.com # 抄送(支持list)spring:  mail:    host: smtp.163.com    port: 25    password: ceshi123456    username: ceshi@163.com
@SpringBootApplication// 切面@EnableExceptionHandle(value = "execution(* com.lihang.exception.client.controller.*.*(..))")public class ExceptionCilentApplication {    public static void main(String[] args) {        SpringApplication.run(ExceptionCilentApplication.class, args);    }}

结果展示