MyBatis中映射文件namespace的作用
在传统的DAO整合中,即手动在DaoImp中写查询语句时,这里的namespace表示唯一标识符,名称可以随意,只要sql语句执行的时候加上namespace前缀即可。但是如果使用接下来的mapper接口方式开发整合就必须是对应的mapper接口的全限定类名了!!!
namespace="CustomerMapper"
public class CustomerDaoImpl extends SqlSessionDaoSupport implements CustomerDao {
// 根据id查询客户
@Override
public Customer findCustomerById(Integer id) {
return this.getSqlSession().selectOne("CustomerMapper.findCustomerById", id);
}
}
在面向接口整合spring时,即不用手动编写实现类,就必须是接口的包了。
namespace="com.itheima.mapper.CustomerMapper"