获取Spring Bean 的几种方法.
来源:互联网 发布:在线网络直播电视 编辑:程序博客网 时间:2024/05/12 07:27
1 .WebApplicationContextUtils .getRequiredWebApplicationContext(servlet.getServletContext());
public Object getBean(String name)
{
if (ctx == null)
{
ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(servlet.getServletContext());
}
return ctx.getBean(name);
}
2. public static void main(final String[] args) throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", Boot.class); //必需放在WEB-INF/lib/class下面
FooService fooService = (FooService) ctx.getBean("fooService");
fooService.insertFoo (new Foo());
}
3. ApplicationContext ctx = new FileSystemXmlApplicationContext(new String[] { "src/cn/com/jbaptech/po/applicationContext.xml" });ctx.getBean("fooService");
- 获取Spring Bean 的几种方法.
- spring获取bean的几种方法
- Spring获取Bean的几种方式
- Spring获取Bean的几种方式
- Spring获取Bean的几种方式
- Spring获取Bean的几种方式
- Spring获取Bean的几种方式
- Spring获取Bean的几种方式
- spring获取bean的几种方式
- spring 获取bean的几种方式
- spring 获取Bean的几种方式
- Spring获取bean的几种方式
- spring 几种获得bean的方法
- Spring获取bean的种方法
- Spring Bean装配--Resource(获取文件的几种常用方法)
- Spring框架下获取Bean的几种方式
- Spring获取Bean的几种方式 分享
- Spring框架下获取Bean的几种方式
- 技术代沟
- 基于Log4j灵活编写日志类
- WinCE开发的一般问题
- java与数据库的所有连接方式
- 熊猫烧香核心源代码,顺便b4一下CSDN的blog系统
- 获取Spring Bean 的几种方法.
- 使用Tomcat-5.5.20配置数据库连接池详细介绍
- C#实现从FTP服务器下载压缩文件并解压.
- 电脑蓝屏代码全集
- java中创建文件目录
- 计算机系统安全之利用操作系统自带命令杀毒
- 页面传递参数方法汇集
- Perl 中的正则表达式 基础
- map 基本用法 (输入字符串与数值,统计输入字符串次数及该数据的平均值)