设为首页 加入收藏

TOP

SpringBoot3进阶用法(三)
2023-08-26 21:11:25 】 浏览:94
Tags:SpringBoot3
w MimeMessageHelper(mimeMessage, true); // 邮件发送方From和接收方To helper.setFrom(userName); helper.setTo(toUsers); // 邮件主题和内容 helper.setSubject(subject); helper.setText(content); // 邮件中的附件 File attachFile = ResourceUtils.getFile(attachPath); helper.addAttachment(attachFile.getName(), attachFile); // 执行邮件发送命令 sender.send(mimeMessage); return "send...mail...sus" ; } }

测试结果

六、应用监控

1、监控配置

springbootactuator组件中,可以通过提供的Rest接口,来获取应用的监控信息;

# 应用监控配置
management:
  endpoints:
    web:
      exposure:
        # 打开所有的监控点
        include: "*"
      base-path: /monitor
  endpoint:
    health:
      enabled: true
      show-details: always
    beans:
      enabled: true
    shutdown:
      enabled: true

2、相关接口

2.1 Get类型接口:主机:端口/monitor/health,查看应用的健康信息,三个核心指标:status状态,diskSpace磁盘空间,ping检查;

{
    /* 状态值 */
	"status": "UP",
	"components": {
	    /* 磁盘空间 */
		"diskSpace": {
			"status": "UP",
			"details": {
				"total": 250685575168,
				"free": 112149811200,
				"threshold": 10485760,
				"path": "Path/butte-spring-parent/.",
				"exists": true
			}
		},
		/* Ping检查 */
		"ping": {
			"status": "UP"
		}
	}
}

2.2 Get类型接口:主机:端口/monitor/beans,查看bean列表;

{
	"contexts": {
		"boot-senior": {
			"beans": {
				"asyncPool": {
					"scope": "singleton",
					"type": "org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor",
					"resource": "class path resource [com/boot/senior/schedule/PoolConfig.class]"
				},
				"asyncService": {
					"scope": "singleton",
					"type": "com.boot.senior.schedule.AsyncService$$SpringCGLIB$$0"
				}
			}
		}
	}
}

2.3 Post类型接口:主机:端口/monitor/shutdown,关闭应用程序;

{
    "message": "Shutting down, bye..."
}

七、参考源码

文档仓库:
https://gitee.com/cicadasmile/butte-java-note

源码仓库:
https://gitee.com/cicadasmile/butte-spring-parent
首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Java后端07(Spring) 下一篇从零玩转系列之微信支付实战PC端..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目