File tree Expand file tree Collapse file tree 22 files changed +366
-3
lines changed
lab-34-actuator-demo-info
java/cn/iocoder/springboot/lab50/maildemo
test/java/cn/iocoder/springboot/lab50/maildemo
java/cn/iocoder/springboot/lab51/sentrydemo
java/cn/iocoder/springboot/lab51/sentrydemo Expand file tree Collapse file tree 22 files changed +366
-3
lines changed Original file line number Diff line number Diff line change 120
120
121
121
* [ 《芋道 Spring Boot 日志集成 Logging 入门》] ( http://www.iocoder.cn/Spring-Boot/Logging/?github ) 对应 [ lab-37] ( https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-37 )
122
122
* [ 《芋道 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 )
123
124
124
125
## 链路追踪
125
126
267
268
268
269
Spring Boot 优雅关闭示例。
269
270
271
+ # lab-50
272
+
273
+ Email 示例
Original file line number Diff line number Diff line change 10
10
</parent >
11
11
<modelVersion >4.0.0</modelVersion >
12
12
13
- <artifactId >lab-34-acturator -demo-info</artifactId >
13
+ <artifactId >lab-34-actuator -demo-info</artifactId >
14
14
15
15
<dependencies >
16
16
<!-- 实现对 Spring MVC 的自动化配置 -->
Original file line number Diff line number Diff line change 10
10
</parent >
11
11
<modelVersion >4.0.0</modelVersion >
12
12
13
- <artifactId >lab-34-acturator -demo</artifactId >
13
+ <artifactId >lab-34-actuator -demo</artifactId >
14
14
15
15
<dependencies >
16
16
<!-- 实现对 Spring MVC 的自动化配置 -->
Original file line number Diff line number Diff line change 10
10
</parent >
11
11
<modelVersion >4.0.0</modelVersion >
12
12
13
- <artifactId >lab-34-acturator -test</artifactId >
13
+ <artifactId >lab-34-actuator -test</artifactId >
14
14
15
15
<dependencies >
16
16
<!-- 实现对 Spring MVC 的自动化配置 -->
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
1
+ package cn .iocoder .springboot .lab50 .maildemo ;
2
+
3
+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
4
+
5
+ @ SpringBootApplication
6
+ public class Application {
7
+ }
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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 >
You can’t perform that action at this time.
0 commit comments