获取所有bean的名字
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
WebApplicationContext ac = ContextLoaderListener.getCurrentWebApplicationContext();
//ApplicationContext ac = SpringContext.getApplicationContext();
String[] strings=ac.getBeanDefinitionNames();
System.out.println(strings.length); AutowireCapableBeanFactory beanFactory = ac.getAutowireCapableBeanFactory();
beanFactory.autowireBean(a);
String name = a.getClass().getName();
beanFactory.initializeBean(a, name);
strings=ac.getBeanDefinitionNames();
System.out.println(strings.length);
for (String string : strings) {
System.out.println(string);
}
获取所有bean的名字的更多相关文章
- spring aop切面中获取代理bean的名字以及bean
//切面中搞: Map<String , Object> map = (Map)ApplicationContextHelper.getBean(proceedingJoinPoint.g ...
- 7 -- Spring的基本用法 -- 10... 获取其他Bean的属性值;获取Field值;获取任意方法的返回值
7.10 高级依赖关系配置 组件与组件之间的耦合,采用依赖注入管理:但基本类型的成员变量值,应直接在代码中设置. Spring支持将任意方法的返回值.类或对象的Field值.其他Bean的getter ...
- 转!!spring @component 详解 默认初始化bean的名字 VNumberTask类 就是 VNumberTask
参考链接:信息来源 今天碰到一个问题,写了一个@Service的bean,类名大致为:CUser xml配置: <context:component-scan base-package=&quo ...
- spring和hibernate整合时报sessionFactory无法获取默认Bean Validation factory
Hibernate 3.6以上版本在用junit测试时会提示错误: Unable to get the default Bean Validation factory spring和hibernate ...
- mysql 获取所有的数据库名字
mysql 获取所有的数据库名字 一.如果使用的是mysqli: $con = @mysqli_connect("localhost", "root", &qu ...
- Spring-程序中获取注册bean的方式
获得spring里注册Bean的四种方法,特别是第三种方法,简单: 一:方法一(多在struts框架中)继承BaseDispatchAction import com.mas.wawacommuni ...
- SpringBoot 注册拦截器方式及拦截器如何获取spring bean实例
SpringBoot 注册拦截器时,如果用New对象的方式的话,如下: private void addTokenForMallInterceptor(InterceptorRegistry regi ...
- 配置springmvc在其他类中(spring容器外)获取注入bean
学习https://github.com/thinkgem/jeesite 今天在写JedisUtils的时候要注入JedisPool,而这个属性被设置为static,@Resource和@Autow ...
- 获取spring bean的utils
<span style="font-size:10px;">package com.record.util; import org.springframework.be ...
随机推荐
- 使用gdb调试c/c++代码
转自 http://blog.csdn.net/haoel/article/details/2879 GDB概述———— GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具.或许,各位比较 ...
- Vue 数组中更新属性值后,视图不更新,等待其他元素更新后会触发的解决办法
因为 JavaScript 的限制,Vue.js 不能检测到下面数组变化: 直接用索引设置元素,如 vm.items[0] = {}: 修改数据的长度,如 vm.items.length = 0. t ...
- 练习E-R图书管理数据库
- 【POJ 3580】SuperMemo Splay
题意 给定$n$个数,$m$个询问,每次在$[L,R]$区间加上一个数,或者反转一个区间$[L,R]$,或者循环右移区间$[L,R]$共$T$次,或者在第$x$个数后插入一个数$p$,或者删除第$x$ ...
- PS 滤镜— —扇形warp
clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...
- [acm]HDOJ 3082 Simplify The Circuit
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3082 字符串处理+并联电阻公式 //11481261 2014-08-18 16:52:47 Acc ...
- CodeForces - 123E Maze
http://codeforces.com/problemset/problem/123/E 题目翻译:(翻译来自: http://www.cogs.pw/cogs/problem/problem.p ...
- 【Lintcode】153.Combination Sum II
题目: Given a collection of candidate numbers (C) and a target number (T), find all unique combination ...
- Java多线程加强
一.传统多线程 public void start() Causes this thread to begin execution; the Java Virtual Machine calls th ...
- JavaScript的中类型转换
JavaScript的类型转换 By 大志若愚 (一)转换为字符串 X + '' toString() String() 函数转换为字符串一般是将函数体输出,不过可以重写其toString方法 ( ...