Spring in Tomcat
来源:互联网 发布:java处理大量数据 编辑:程序博客网 时间:2024/06/05 02:45
可以让tomcat在启动时自动读取spring的配置文件。
只需要在web.xml中配置listener;
<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>它就会自动读取/WEB-INF/下面的applicationContext.xml文件。
如果此xml中配置了一个bean,那么在代码中获得此对象,需要在你的Bean类中实现BeanFactoryAware接口,初始化时由spring自动调用该接口的setBeanFactory()方法。
例子见下:
@Componentpublic class Dao implements BeanFactoryAware {public void setBeanFactory(BeanFactory beanFactory) throws BeansException {dataSource=beanFactory.getBean("dataSource", DataSource.class);}}
0 0
- Spring in Tomcat
- Spring JTA multiple resource transactions in Tomcat with Atomikos example
- Spring JTA multiple resource transactions in Tomcat with Atomikos example
- Learn Spring in spring
- Digester in Tomcat
- ClassLoader in Tomcat[转贴]
- Logging in Tomcat
- Digester in Tomcat
- HTTPS in Tomcat
- Install tomcat in Ubuntu
- install tomcat in mac
- Learn Spring in spring(一)
- Learn Spring in spring(二)
- Learn Spring in spring(三)
- Learn Spring in spring(2)
- Learn Spring in spring(3)
- Learn Spring in spring(四)
- Learn Spring in spring(一)
- 2005年11月 test
- ffmpeg只转封装不转码的代码实现
- Java设计模式之单例模式SingleTon
- HTML5 - 用户注册表单
- https://leetcode.com/problems/spiral-matrix-ii/
- Spring in Tomcat
- 几个地图(高德、百度、Apple、Google)URL API
- 感慨
- facebook Fresco框架库源使用基础
- SQLite: sqlite_master
- js统计图表制作圆环图
- 关于Go 和Erlang的一些想法
- 动态的删除Hadoop集群的节点(白名单与黑名单)
- TCP/IP中那些令人豁然开朗的说明