jfinal和spring整合问题

weixin_38054205 2016-01-27 10:21:14
@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清空,谢谢
...全文
24 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧