简体   繁体   English

如何找到给定的Spring Boot类/包的bean列表?

[英]How do I find a list of beans for a given Spring Boot class/package?

I am currently working with Spring Boot with a number of starter packs, such as the web MVC framework, Thymeleaf templates and security. 我目前正在使用带有许多入门包的Spring Boot ,例如Web MVC框架,Thymeleaf模板和安全性。

Each of these packages have a lot of different configuration options. 这些软件包中的每一个都有许多不同的配置选项。 I have mainly been using the source from the Auto-configuration package to figure out which beans need to be wired up and how to do that. 我主要使用自动配置包中的源来确定需要连接哪些bean以及如何进行连接。

However, Is there any easy way to find a list of expected beans/classes that are needed by a given Spring package? 但是,是否有任何简单的方法来查找给定Spring包所需的预期bean /类的列表?

To view the beans you can you spring boot actuator 要查看豆子,您可以弹簧启动执行器

To Enable actuator, you can simply add the actuator starter dependency to your project. 要启用执行器,您只需将执行器启动器依赖项添加到您的项目中。

For Gradle 对于摇篮

compile("'org.springframework.boot:spring-boot-starter-actuator:1.3.1.RELEASE'
")

For Maven 对于Maven

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
    <version>1.3.1.RELEASE</version>
</dependency>

You can skip the version if you are using spring boot parent pom 如果您使用的是Spring Boot Parent Pom,则可以跳过该版本

Now you can rebuild your application make get request to http://server:port/beans if local and port is 8080 then 现在,如果本地和端口为8080,则可以重建应用程序对http://server:port/beans get请求。

http://localhost:8080/beans

If you want to access using CURL command line tool you can 如果要使用CURL命令行工具访问,可以

curl http://localhost:8080/beans

For more information visit 欲了解更多信息,请访问

http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM