美文网首页
mapper注入失败:nested exception is o

mapper注入失败:nested exception is o

作者: 崔可仁 | 来源:发表于2019-06-21 22:31 被阅读0次

1、检查dispatcher-database.xml是否扫描到mapper文件,发现扫描到了

2、通过new ClassPathXmlApplicationContext("applicationContext.xml")实例化一个,调用它的getBean()方法,可以获取mapper对象,说明mapper对象可以被创建并交由spring工厂管理,所以推测是spring配置文件没有被web.xml加载。

3、检查web.xml发现没有配置监听器

加入

<listener>

  <listener-class>

      org.springframework.web.context.ContextLoaderListener

    </listener-class>

</listener>

new ClassPathXmlApplicationContext("applicationContext.xml")

ServletContextListener使用详解以及web容器中获取spring容器

相关文章

网友评论

      本文标题:mapper注入失败:nested exception is o

      本文链接:https://www.haomeiwen.com/subject/ozdpqctx.html