集成 spring-boot-starter-actuator 用于监控 spring-boot 的启动和运行状态
前言
此系列博客是个人在学习springBoot的学习笔记,算是一个记录吧,一方面记录学习的内容,一方面记录学习中犯下的错误。学习springBoot选择的是GitHub上一个比较著名的项目,链接如下https://github.com/xkcoding/spring-boot-demo.git。这是一个从易到难的项目,目标:完成本地实现。技术差,文笔差,学习能力差,啥都差,欢迎指正,拒绝喷人
一、demo是什么?
本 demo 主要演示了如何在 Spring Boot 中通过 actuator 检查项目运行情况,代码不多,主要是配置文件。注意事项有几点,
1.项目的主系统端口和信息端口分开,简而言之你如果看信息要访问8090,即你配置的端口,而不是8080,这是在yml文件中配置。
2.项目不需要写登陆页面,直接使用的security自带的login页面。
3.用户名密码在yml中配置,所以也不需要连接数据库。
4.actuator的用法很多,可以查看的内容也很多,这只是个简单配置,建议多看看博客,然后多运行几次看看内容。
5.输入访问网址时注意application.yml配置了context-path,要加上配置的内容,
二、使用步骤
1.新建子模块
1.1 新建多模块项目见系列第一篇。这是多模块项目下的一个子模块。
1.2 导入maven依赖
父模块pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xkcoding</groupId>
<artifactId>spring-boot-learning-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<!-- 子模块-->
<modules>
<module>spring-boot-demo-helloworld</module>
<module>spring-boot-demo-properties</module>
<module>spring-boot-demo-actuator</module>
<!-- 以后才会用先注释掉-->
<!--
<module>spring-boot-demo-admin</module>
<module>spring-boot-demo-logback</module>
<module>spring-boot-demo-log-aop</module>
<module>spring-boot-demo-exception-handler</module>
<module>spring-boot-demo-template-freemarker</module>
<module>spring-boot-demo-template-thymeleaf</module>
<module>spring-boot-demo-template-beetl</module>
<module>spring-boot-demo-template-enjoy</module>
<module>spring-boot-demo-orm-jdbctemplate</module>
<module>spring-boot-demo-orm-jpa</module>
<module>spring-boot-demo-orm-mybatis</module>
<module>spring-boot-demo-orm-mybatis-mapper-page</module>
<module>spring-boot-demo-orm-mybatis-plus</module>
<module>spring-boot-demo-orm-beetlsql</module>
<module>spring-boot-demo-upload</module>
<module>spring-boot-demo-cache-redis</module>
<module>spring-boot-demo-cache-ehcache</module>
<module>spring-boot-demo-email</modu