解决 Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

在Spring3和Mybatis3整合的时候,dao层注入'sqlSessionFactory'或'sqlSessionTemplate'会报错解决办法如下

package com.alibaba.webx.MyWebxTest.myWebX.module.dao.impl;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 公用的DAO
 * @author zkn
 *
 */

public abstract class AbstractDao extends SqlSessionDaoSupport{

	/**
	 * Autowired 必须要有
	 */
	@Autowired
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory){

        super.setSqlSessionFactory(sqlSessionFactory);
    }

}

原因是因为Mybatis3依赖的jar位 mybatis-spring-1.2.0.jar,这个版本及以上的版本中对SqlSessionDaoSupport类中的'sqlSessionFactory'或'sqlSessionTemplate'注入方式进行了调整。

 

时间: 2024-09-21 18:40:38

解决 Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required的相关文章

php 解决MySQL插入数据出现 Incorrect string value: '\xF0\x9F\x92\x8BTi...'错误

在项目中向MySQL插入数据时,发现数据插入不完整,通过调试,发现插入语句也没什么特殊的错误.但是就是差不进去,于是就打开mysqli错误的调试 $ret = mysqli_query($this->conn, $sql) or die(mysqli_error($this->conn)); 结果弹出如下错误信息: Incorrect string value: '\xF0\x9F\x92\x8BTi...' 有错误信息就好办了,结果上网一查结果是:mysql编码格式utf-8格式,不支持带四

python新手求助-初学者python 'str' object has no attribute 'vals' 怎么解决啊

问题描述 初学者python 'str' object has no attribute 'vals' 怎么解决啊 代码如下 import sqlite3 def convert(value): if value.startswith('~'): return value.strip('~') if not value: value = '0' return float(value) conn=sqlite3.connect('food.db') curs=conn.cursor() try:

MYSQL错误解决:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 据说这个问题的原因很多,当然,我自己这个问题我是清楚的,就是mysql.sock的位置所致,一个是PHP要求的,一个是MYSQLD定义的,一个是MY.CONF指定的...SO.... 暂时不能统一的话,用软链接LN -S命令解决吧..   方案5      摘要:解决不能通过mysql .so

解决FatalThrowableError in EloquentUserProvider.php line 126: Class '\App\User'问题

解决方法:http://stackoverflow.com/questions/28516454/laravel-5-user-model-not-found 总结:是因为我把app下的User移动到app\Models下了,所以You need to update your config/auth.php file. Change 'model' => 'App\User' to 'model' => 'App\Models\User'.

未解决Unable to use slave's temporary directory /tmp - Can't create/write to file '/tmp/SQL_LOAD-' (Err

  Login / Register Developer Zone Bugs Home Report a bug Statistics Advanced search Saved searches Tags Bug #62055 Race condition in check_temp_dir() from multiple mysqld instances Submitted: 2 Aug 2011 10:24 Modified: 19 Dec 2011 1:29 Reporter: Yosh

python-'GridFS' object has no attribute 'find'

问题描述 'GridFS' object has no attribute 'find' 1C File ""E:codetake.py"" line 52 in take for s in fs.find({'packageName':doc['_id']}): AttributeError: 'GridFS' object has no attribute 'find' 请问各位朋友我python中报这个错误是什么原因,该如何解决呢?下面是我的代码:#!/bin

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (

mysql启动成功 service mysqld start  mysql is OK mysql登录错误 : [root@localhost ~]# mysql -uroot -p123456ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 解决: vim /etc/my.cnf 找到 socket路径 scoket=/tmp/mysql.

connection to dat Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

[root@t1 ~]# tail /tmp/zabbix_server.log  23392:20160303:131022.598 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  23392:20160303:131022.598 Database is down.

IDEA报错Target level '1.6' is incompatible with source level '1.7'

解决IDEA 编译级别 Error:java: Target level '1.6' is incompatible with source level '1.7'. A target level '1.7' or better is required 打开之后发现有一个编译级别设置的不对 更改如下: 如果上面的方法还是不行的话,就建议你改一下pom文件中的maven插件编译级别,可以通过搜索所有的pom.xml,1.6这个关键词,就看出来了. <profiles> <profile&g