获取所有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 ...
随机推荐
- laravel基础课程---11、lavarel的ajax操作(ajax优劣势是什么)
laravel基础课程---11.lavarel的ajax操作(ajax优劣势是什么) 一.总结 一句话总结: 优势:用户友好度:异步通信,不会频繁刷新页面,用户友好度比较高 优势:减轻数据库压力 缺 ...
- exec 和 spawn 的区别
参考资料: difference-between-spawn-and-exec-of-node-js-child_process process_child 最近在用nodejs 的child_pro ...
- linux命令学习笔记(29):chgrp命令
在lunix系统里,文件或目录的权限的掌控以拥有者及所诉群组来管理.可以使用chgrp指令取变更文件与目录所属群 组,这种方式采用群组名称或群组识别码都可以.Chgrp命令就是change group ...
- CardView以及RecycleView的一些问题
下面这些属性在listview的标签里有用,在recyclerView里没用. tools:listitem="@layout/list_single_answer_item_borrowe ...
- nginx rewrite 导致验证码不正确
配置nginx里url rewrite的时候,为了使浏览器地址栏的URL保持不变, 使用proxy_pass反向代理,但发现每次都会生成新的jsessionid 解决方法,配置中增加 proxy_co ...
- 【LeetCode】259 3Sum Smaller
题目: Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 ...
- vue之axios请求数据本地json
写给自己的话:静态的json文件要记得放在static文件夹下,想打自己 1.下载插件 npm install axios --save 2.在main.js下引用axios import axios ...
- 选中DataGrid的Cell而不是row
主要是针对DataGridCellsPresenter而不是SelectiveScrollingGrid,使用时DataGridRow应用这个style就可以了. <Style x:Key=&q ...
- bzoj5093
NTT+组合数学 $把每个点分别按度数考虑,由于有标号,可以得出$ $ans=n*2^{(n-1)*(n-2)}*\sum_{i=1}^{n-1}{C(n-1,i)*i^{k}}$ $本质上是求\su ...
- Session与Cookie(1)
Session session是一种位于服务端,用于存储一个会话(指打开浏览器访问某个域名,及其下面的资源,然后关掉浏览器的过程)中所需的配置信息.也就是在一个会话中,只存在一个session.对于J ...