Is there a way to print all the spring beans that are loaded on startup?I am using Spring 2.0.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Print all bean names and its classes:
applicationContext.getBeanDefinitionNames() does not show the beans which are registered without BeanDefinition instance.
}
Console Output
As you can see in the output, environment, systemProperties, systemEnvironment beans will not be shown using context.getBeanDefinitionNames() method.
Spring Boot
For spring boot web applications, all the beans can be listed using the below endpoint.
}
Using
spring-boot-starter-actuator
you can easily access all bean.Here is the setup process:
Add bellow into gradle file:
Add
management.security.enabled=false
into your application.property filecall /beans endpoint:
After that setup spring will enable some metrics related endpoints. One of its endpoint is /beans After calling this endpoints it will provide a json file that contains all of your bean including it's dependency and scope.
Here is an example json file:
For more info visit bellow links:
Hope this will help you. Thanks :)
You could try calling
Or turn on debug logging for
org.springframework
. (In spring boot, that's using a parameter--logging.level.org.springframework=DEBUG
)Here is another way to print all the bean names from the spring application context: