在Spring4和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'注入方式进行了调整。

Spring整合Mybatis解决 Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required的更多相关文章

  1. SpringBoot+MyBatis整合报错Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    项目启动的时候报这个错误,这个问题我百度了一天,果然不出意外的还是没能解决,其中有一篇文章相对来说还是有点用的:https://blog.csdn.net/qq8693/article/details ...

  2. Springboot 2.0.4 整合Mybatis出现异常Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    在使用Springboot 2.0.4 整合Mybatis的时候出现异常Property 'sqlSessionFactory' or 'sqlSessionTemplate' are require ...

  3. springboot整合mybatis的时候报错Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    今天闲来无事,学习springboot整合mybatis,在bilibili看视频学的,视频中在dao层的interface上面加上org.apache.ibatis.annotations.Mapp ...

  4. springmvc与mybatis整合时 java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required 异常

    今天在整合springmvc与mybatis时,启动服务器遇到这样一个问题, by: java.lang.IllegalArgumentException: Property 'sqlSessionF ...

  5. spring boot 2.0.0 + mybatis 报:Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    spring boot 2.0.0 + mybatis 报:Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required 无法启动 ...

  6. MyBatis与Spring MVC结合时,使用DAO注入出现:Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    错误源自使用了这个例子:http://www.yihaomen.com/article/java/336.htm,如果运行时会出现如下错误: Invocation of init method fai ...

  7. Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required [ IDEA mybatis项目报错 ]

    今天笔者用Springboot框架整合Mybatis做一个小小的项目: 代码写完,在运行项目时,IDEA给我报了3处错误: org.springframework.beans.factory.Unsa ...

  8. 使用 Jenkins 打包成功后 运行 出现 Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    linux 运行时 错误日志 Error starting ApplicationContext. To display the conditions report re-run your appli ...

  9. Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'e ...

随机推荐

  1. boa.config

    # boa -c /usr/local/boa Port 80 #User 0#Group 0 ErrorLog /dev/console AccessLog /dev/console ServerN ...

  2. oracle数据库触发器(trigger)用法总结

    from:http://blog.csdn.net/zhanzhib/article/details/48729417 触发器的意思就是当我们对数据库对象(一般是表或视图)进行insert.updat ...

  3. Spring new对象时注解失效

    新建了一个新类(A)后,在类中用注解将属性注入.类名(A)上用 @Component ,类中的一个属性(name)上用 @Autowired或@Resource, 方法(fun)中通过 属性(name ...

  4. 钟意Action

    package com.j1.mai.action; import com.github.pagehelper.PageInfo; import com.j1.app.mysql.model.Appr ...

  5. Memcache命令及参数用法

    Memcache命令:在linux下: # /usr/local/bin/memcached -d -m 128 -u root -l 192.168.0.10 -p 12121 -c 256 -P ...

  6. Mybatis中的foreach

    <delete id="deleteByParam"> DELETE FROM YZ_SECURITIES_CURRENCY WHERE ID IN <forea ...

  7. exports和module.exports区别

    参考:module.exports与exports的区别.关于exports的总结 exports 和 module.exports 的区别 module.exports是真正的模块接口,而expor ...

  8. 【BZOJ2743】[HEOI2012]采花 离线+树状数组

    [BZOJ2743][HEOI2012]采花 Description 萧芸斓是Z国的公主,平时的一大爱好是采花. 今天天气晴朗,阳光明媚,公主清晨便去了皇宫中新建的花园采花.花园足够大,容纳了n朵花, ...

  9. Appium中长按按钮操作

    在一次项目中,appium要对某个按钮进行长按操作(大于2s),类似拍微信小视频,参考网上长按视频会报错 action1 = TouchActions(self.driver) el = self.d ...

  10. undo文件丢失或损坏

    startup mount cp +DATA/ora11g/datafile/undotbs1.dbf alter database rename file '+DATA/ora11g/datafil ...