Skip to content

Commit 1e5d414

Browse files
author
YunaiV
committed
增加 spring boot x sentry
1 parent ec7cb88 commit 1e5d414

File tree

22 files changed

+366
-3
lines changed

22 files changed

+366
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120

121121
* [《芋道 Spring Boot 日志集成 Logging 入门》](http://www.iocoder.cn/Spring-Boot/Logging/?github) 对应 [lab-37](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-37)
122122
* [《芋道 Spring Boot 日志平台 ELK + Filebeat 入门》](http://www.iocoder.cn/Spring-Boot/ELK/?github) 对应 [lab-38](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-38)
123+
* [《芋道 Spring Boot 异常管理平台 Sentry 入门》](http://www.iocoder.cn/Spring-Boot/Sentry/?github) 对应 [lab-51](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-51)
123124

124125
## 链路追踪
125126

@@ -267,3 +268,6 @@
267268

268269
Spring Boot 优雅关闭示例。
269270

271+
# lab-50
272+
273+
Email 示例

lab-34/lab-34-actuator-demo-info/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212

13-
<artifactId>lab-34-acturator-demo-info</artifactId>
13+
<artifactId>lab-34-actuator-demo-info</artifactId>
1414

1515
<dependencies>
1616
<!-- 实现对 Spring MVC 的自动化配置 -->

lab-34/lab-34-actuator-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212

13-
<artifactId>lab-34-acturator-demo</artifactId>
13+
<artifactId>lab-34-actuator-demo</artifactId>
1414

1515
<dependencies>
1616
<!-- 实现对 Spring MVC 的自动化配置 -->

lab-34/lab-34-actuator-test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212

13-
<artifactId>lab-34-acturator-test</artifactId>
13+
<artifactId>lab-34-actuator-test</artifactId>
1414

1515
<dependencies>
1616
<!-- 实现对 Spring MVC 的自动化配置 -->

lab-50/lab-50-demo/pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.2.2.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>lab-50-demo</artifactId>
14+
15+
<dependencies>
16+
<!-- 实现对 Java Mail 的自动化配置 -->
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-mail</artifactId>
20+
</dependency>
21+
22+
<!-- 方便等会写单元测试 -->
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-test</artifactId>
26+
<scope>test</scope>
27+
</dependency>
28+
</dependencies>
29+
30+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package cn.iocoder.springboot.lab50.maildemo;
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
5+
@SpringBootApplication
6+
public class Application {
7+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#spring:
2+
# mail: # 配置发送告警的邮箱
3+
# host: smtp.163.com
4+
# port: 465
5+
# protocol: smtps
6+
# username: yudaoyuanma@163.com
7+
# password: '***'
8+
# default-encoding: UTF-8
9+
## properties:
10+
## smtp:
11+
## auth: true
12+
## starttls:
13+
## enable: true
14+
## required: true
15+
16+
17+
spring:
18+
mail: # 配置发送告警的邮箱
19+
host: smtp.exmail.qq.com
20+
port: 465
21+
protocol: smtps
22+
username: yunai.wang@medcloud.cn
23+
password: '***'
24+
default-encoding: UTF-8
25+
properties:
26+
smtp:
27+
auth: true
28+
starttls:
29+
enable: true
30+
required: true
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package cn.iocoder.springboot.lab50.maildemo;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.beans.factory.annotation.Value;
7+
import org.springframework.boot.test.context.SpringBootTest;
8+
import org.springframework.mail.SimpleMailMessage;
9+
import org.springframework.mail.javamail.JavaMailSender;
10+
import org.springframework.test.context.junit4.SpringRunner;
11+
12+
@RunWith(SpringRunner.class)
13+
@SpringBootTest(classes = Application.class)
14+
public class ApplicationTests {
15+
16+
@Autowired
17+
private JavaMailSender mailSender;
18+
19+
@Value("${spring.mail.username}")
20+
private String username;
21+
22+
@Test
23+
public void testSend() {
24+
SimpleMailMessage message = new SimpleMailMessage();
25+
message.setFrom(username);
26+
message.setTo("7685413@qq.com");
27+
message.setSubject("我是测试主题");
28+
message.setText("我是测试内容");
29+
30+
mailSender.send(message);
31+
}
32+
33+
}

lab-50/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>labs-parent</artifactId>
7+
<groupId>cn.iocoder.springboot.labs</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>lab-50</artifactId>
13+
<packaging>pom</packaging>
14+
<modules>
15+
<module>lab-50-demo</module>
16+
</modules>
17+
18+
19+
</project>

lab-51/lab-51-sentry-logback/pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.2.2.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>lab-51-sentry-logback</artifactId>
14+
15+
<dependencies>
16+
<!-- 实现对 Spring MVC 的自动化配置 -->
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-web</artifactId>
20+
</dependency>
21+
22+
<!-- Sentry 对 Logback 的拓展,实现通过打日志的方式,来上传日志到 Sentry 服务 -->
23+
<dependency>
24+
<groupId>io.sentry</groupId>
25+
<artifactId>sentry-logback</artifactId>
26+
<version>1.7.30</version>
27+
</dependency>
28+
</dependencies>
29+
30+
</project>

0 commit comments

Comments
 (0)