前言
在日常开发&测试过程中,有时候需要排查某个bean实例创建实例
解决办法
-
通过 actuator 功能查看运行环境中所有的spring bean
-
简介:actuator是spring boot的一个附加功能,可帮助你在应用程序生产环境时监视和管理应用程序。可以使用HTTP的各种请求来监管,审计,收集应用的运行情况,特别对于微服务管理十分有意义。
具体操作
- 在pom.xml文件中添加actuator 依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
- 运行Spring Boot项目后如下查看页面即可查询运行过程中创建的bean实例
- 另外还支持页面查看(ip:port/actuator/beans)