Spring Boot 给我们提供了 Actuator 这个包,这个包的关键特性是在应用程序中提供众多的web端点, 通过他们了解应用程序运行时内部的状况, 在 Maven 里面加入依赖, 程序启动起来以后我们就可以通过访问 **/env **/beans ... 等等路径来了解程序运行过程中的信息
actuator : 我可能和计算机关系比较好, 不信你看看你能看懂吗? -_- <不过用起来真的方便>
为了对actuator提供的程序内部的信息可视化并且进行很方便的管理, 需要用到spring 的另外一个包
(spring-boot-admin)
使用 admin 这个包我们可以构造一个web程序(server)
构造起来很简单只需要建立 spring boot 工程, 在maven中加入
de.codecentric spring-boot-admin-starter-server2.3.1
在入口类上面加上下面的注解
@EnableAdminServer
打包发布就行了 我的spring boot 版本是 2.4.0, 如果报错了那大概率就是 admin 的版本不对client 端
我们只需要对需要监控的程序进行如下配置
- pom.xml
de.codecentric spring-boot-admin-starter-client2.3.1 org.springframework.boot spring-boot-starter-actuator
- application.properties
server.port = 9090 management.endpoints.web.exposure.include=* spring.boot.admin.client.url=http://localhost:8080
spring.boot.admin.client.url=http://localhost:8080 :这个配置指定了服务器的地址 management.endpoints.web.exposure.include=* :这个配置指定了actuator开放的信息 server.port = 9090 : 指定本程序使用的端口号
使用 actuator的时候记得开启 security模块 ....
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)