怎样查看spring容器有哪些bean

来源:互联网 发布:东方证券行情软件 编辑:程序博客网 时间:2024/06/05 17:10

测试类:


public static void main(String args[]) {
ApplicationContext context=new ClassPathXmlApplicationContext("classpath:spring-applicationContext.xml");
Object user= context.getBean("userController");
String[] str=context.getBeanDefinitionNames();
for (String string : str) {
System.out.println("..."+string);
}
System.out.println("----"+user);

}


结果:

...scPropertyPlaceholderConfigurer
...mvcContentNegotiationManager
...org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
...mvcCorsConfigurations
...org.springframework.format.support.FormattingConversionServiceFactoryBean#0
...org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter
...mvcUriComponentsContributor
...org.springframework.web.servlet.handler.MappedInterceptor#0
...org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0
...org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0
...org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0
...org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping
...org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter
...org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter
...validator
...messageSource
...org.springframework.context.annotation.internalConfigurationAnnotationProcessor
...org.springframework.context.annotation.internalAutowiredAnnotationProcessor
...org.springframework.context.annotation.internalRequiredAnnotationProcessor
...org.springframework.context.annotation.internalCommonAnnotationProcessor
...org.springframework.context.annotation.internalPersistenceAnnotationProcessor
...org.springframework.context.event.internalEventListenerProcessor
...org.springframework.context.event.internalEventListenerFactory
...org.springframework.aop.config.internalAutoProxyCreator
...
userController
...userDao
...userService
...dataSource
...sessionFactory
...baseDao
...springContextHolder
...txManager
...txAdvice
...org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0
...exceptionHandler
...org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor
...org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor

原创粉丝点击