加载applicationContext文件的七种方法
来源:互联网 发布:选股器软件 编辑:程序博客网 时间:2024/06/06 04:02
/** 1 把applicationContext.xml放到classpath目录下*/
// Resource resource = new ClassPathResource("applicationContext.xml");
// BeanFactory factory = new XmlBeanFactory(resource);
// JdbcTemplate jt = (JdbcTemplate)factory.getBean("jdbcTemplate");
/** 2*/
// WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(ctx);
// JdbcTemplate jt = (JdbcTemplate) wac.getBean("jdbcTemplate");
/** 3*/
// ApplicationContext ac = new FileSystemXmlApplicationContext("D://apache-tomcat-6.0.29//webapps//jf_shop//WEB-INF//applicationContext.xml");
// JdbcTemplate jt = (JdbcTemplate) ac.getBean("jdbcTemplate");
/** 4*/
// WebApplicationContext wac = (WebApplicationContext)ctx.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
// JdbcTemplate jt = (JdbcTemplate) wac.getBean("jdbcTemplate");
/** 5把applicationContext.xml放到classpath目录下*/
// ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext_ty.xml");
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext(new String[] {"applicationContext_ty.xml","applicationContext.xml","applicationContext_zj.xml","applicationContext_mtb.xml","applicationContext_wll.xml"});
BeanFactory factory = ac;
JdbcTemplate jt = (JdbcTemplate)factory.getBean("jdbcTemplate");
// dao = (PingPaiDao)factory.getBean("dao");
/** 6 必须继承MultiActionController类*/
// JdbcTemplate jt = (JdbcTemplate) getApplicationContext().getBean("jdbcTemplate");
/** 7*/
// XmlWebApplicationContext xctx = new XmlWebApplicationContext();
// xctx.setConfigLocations(new String[] {"/WEB-INF/applicationContext.xml"});
// xctx.setServletContext(ctx);
// xctx.refresh();
/** 8*/
// JdbcTemplate jt = (JdbcTemplate)xctx.getBean("jdbcTemplate");
- 加载applicationContext文件的七种方法
- Spring的ApplicationContext加载Property文件
- Spring的ApplicationContext加载Property文件
- applicationContext.xml的两种加载方式
- applicationContext.xml加载的两种方式:
- J2EE 加载Spring的applicationContext.xml文件的两种方式
- Spring中加载ApplicationContext.xml文件的方式
- Spring中加载ApplicationContext.xml文件的方式
- Spring中加载ApplicationContext.xml文件的方式【转】
- spring 的启动 之加载文件 applicationContext.xml
- Spring中加载ApplicationContext.xml文件的方式
- Spring中加载ApplicationContext.xml文件的方式
- Spring中加载ApplicationContext.xml文件的方式
- Spring中加载ApplicationContext.xml文件的方式
- Spring中加载ApplicationContext.xml文件的方式
- Spring中加载ApplicationContext.xml文件的方式
- ApplicationContext 获取的三种方法
- ApplicationContext 获取的三种方法
- 伪随机数
- Logger.getLogger和 LogFactory.getLog
- 字符编码(ASCII、ANSI、UNICODE及UTF-8编码)
- Android 游戏开发之 SurfaceView
- java中Logger.getLogger(Test.class)
- 加载applicationContext文件的七种方法
- org.springframework.web.struts.ContextLoaderPlugIn 和 org.springframework.web.con
- data = (DataSource)conEnv.lookup("jdbc/mysqlHaoBookShop");
- java main 主函数
- Iterator(迭代器)的一般用法
- JSP里面有关参数传递地疑难 (收藏)
- 小窗口大学问--玩转弹出窗口
- C# 操作Excel单元格格式
- jsp弹出一个窗口,一个对话框