jfinal和spring整合问题
@JFinal 你好,想跟你请教个问题:我用jfinal2.2整合spring的时候,由于是老项目用的spring版本比较老,是2.5.6的,spring的xml文件无法被spring解析导致无法获取ApplicationContext,错误如下:org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext.xml]; nested exception is org.springframework.beans.FatalBeanException: Class [org.springframework.transaction.config.TxNamespaceHandler] for namespace [http://www.springframework.org/schema/tx] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface
这个spring配置文件肯定没有格式错误的,老项目都用了好多年了,用下面这种方法可以获取到spring的ApplicationContext,就是在web.xml配置一个
<listener>
<listener-class>com.shenhua.common.spring.SpringPlugin</listener-class>
</listener>
然后继承ServletContextListener
public class SpringPlugin implements IPlugin,ServletContextListener {
private String[] configurations;
private ApplicationContext ctx;
public SpringPlugin() {
}
public SpringPlugin(String... configurations) {
this.configurations = configurations;
}
public SpringPlugin(ApplicationContext ctx) {
this.ctx = ctx;
}
public boolean start() {
System.out.println(IocInterceptor.ctx+"-----");
// if (ctx != null)
// IocInterceptor.ctx = ctx;
// else if (configurations != null)
// IocInterceptor.ctx = new FileSystemXmlApplicationContext(configurations);
// else
// IocInterceptor.ctx = new FileSystemXmlApplicationContext(PathKit.getWebRootPath() + "/WEB-INF/classes/applicationContext.xml");
return true;
}
public boolean stop() {
return true;
}
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
IocInterceptor.ctx = WebApplicationContextUtils.getWebApplicationContext(servletContextEvent.getServletContext());
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
}
}
其中contextInitialized方法能获取到ApplicationContext,但是start方法打印出来的仍然是null,start注释的方法报的是先前的那个错误,大神帮忙看下怎么解决吧,怎么能把contextInitialized方法里的内容给一个静态全局变量赋值,然后不会被jfinal清空,谢谢