Spring ClassPathXmlApplicationContext疑惑
ApplicationContext.xml文件在使用ClassPathXmlApplicationContext获取Resource对象时,用ClassPathXmlApplicationContext时必须将ApplicationContext.xml放到WEB-INF/classes下面,否则你应该用FileSystemXmlApplicationContext,
然后在web.xml中的<display-name>some your modle info</display-name>后面加上:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/ApplicationContext.xml</param-value>
</context-param>
Spring .xml相关问题
一个切入点类?
用这个吧:
BeanFactoryLocator bfLocator = SingletonBeanFactoryLocator.getInstance();
BeanFactoryReference bf = bfLocator.useBeanFactory("beanFactory");
// now use some bean from factory
return bf.getFactory().getBean(name);
--------------
<beans>
<bean id="beanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>dataAccessContext.xml</value>
<value>securityContext.xml</value>
<value>...</value>
</list>
</constructor-arg>
</bean>
</beans>
如果是WebApplication,用这个也不错。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/myApplicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>