# spring-boot-starter-exnotice **Repository Path**: xmingtx/spring-boot-starter-exnotice ## Basic Information - **Project Name**: spring-boot-starter-exnotice - **Description**: 异常通知插件 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-08-18 - **Last Updated**: 2023-11-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # spring-boot-starter-exnotice - 异常消息通知插件(通过邮件发送异常消息) ### 如何集成 1. 在pom.xml文件中添加如下依赖: ``` com.mk spring-boot-starter-exnotice ${lastest.version} ``` 2. 在启动类上添加`@EnableExceptionNotice`注解,如下: ``` @EnableExceptionNotice @SpringBootApplication public class SsoClientApplication { public static void main(String[] args) { SpringApplication.run(SsoClientApplication.class); } } ``` 3. 在application.yml配置文件中添加如下配置: ``` spring: mail: host: smtp.163.com protocol: smtp default-encoding: UTF-8 username: xxxx@163.com password: xxxx exception: notice: enabled: true project-name: test-logback to: xmingtx@126.com ``` 4. 在需要监听的控制类或者方法上面添加`@ExceptionListener`注解,如下: ``` @GetMapping("/test") @ExceptionListener public String test(){ // 此处执行会抛出异常 int num = 1/0; return "success"; } ``` ### 异常报警详细信息如下 ![异常信息](/demo.png)