Spring + ibatis Error creating bean with name 'sqlMapClient'的问题
这个问题搞了我半天,最近学习了下ibatis ,想想以前就会点JSF +Spring,正好最近为了找工作 ,复习了下,尝试用ibatis代替掉spring jdbctemplate的方式,感受下ORM的快感。
但是始终有错误 。
大体就是用spring来管理ibatis的。
<bean id="sqlMapClient" value="sqlMapConfig.xml"/></bean> <bean id="loginDao" > <property name="sqlMapClient"><ref local="sqlMapClient"/></property> <property name="dataSource" ref="dataSource" /> //还是要的</bean>
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"><sqlMapConfig><sqlMap resource="com/sdyt/vo/Employee.xml"/></sqlMapConfig>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/sqlMapConfig.xml]Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/sqlMapConfig.xml]
public Employee judgeEmp(Employee emp) {try {Object obj = getSqlMapClientTemplate().queryForObject("judgeEmpExist",emp);return (Employee)obj;