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")









网友评论