1. 程式人生 > >解決 Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

解決 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'注入方式進行了調整。

相關推薦

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

在Spring3和Mybatis3整合的時候,dao層注入'sqlSessionFactory'或'sqlSessionTemplate'會報錯解決辦法如下 package com.alibaba.w

springboot+mybatis的實現以及 PropertysqlSessionFactoryorsqlSessionTemplateare required問題的解決

廢話不多說,直接上步驟 前期準備 建表: CREATE TABLE book(id int primary key auto_increment ,bookId bigint,bookName varchar(200)) 插入資料: insert into book

SpringBoot 找不到Dao註解和sqlSessionFactoryorsqlSessionTemplateare required,

SpringBoot簡單搭建報錯:Field userDao in com.example.service.UserService required a bean of type ‘com.example.dao.IUserDao’ that could not

解決Caused by: java.lang.IllegalArgumentException: Property sqlSessionFactory or sqlSessionTemplate ar

啟動tomcat之後日誌裡面報:Caused by: java.lang.IllegalArgumentException: Property sqlSessionFactory or sqlSessionTemplate are required, 網上看了一些文章,基本上是少了:

spring整合mybatis遇到的bug java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

如果 spring tis per div prop seda bat required 出bug的原因:mybatis-spring版本問題。 查看SqlSessionDaoSupport源碼 1.2以上的版本: 1.1.1版本: 解決方法:1.2版本移除了

Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

bean erp ring capable IE prop druid itme sta 錯誤提示: Caused by: java.lang.IllegalArgumentException: Property ‘sqlSessionFactory‘ or ‘sqlSes

spring boot 2.0.0 + mybatis 報:Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

temp 啟動 aid 項目啟動 require class color 重要 缺少 spring boot 2.0.0 + mybatis 報:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are require

成功解決SharePoint2010安裝“Windows ServerFeature or Role Service required by this product are not enabled”

成功解決SharePoint Server 2010安裝第一個伺服器場 如果僅按照MS的簡單說明安裝SharePoint Server 2010的話,很可能跟我的遭遇一樣,安裝程式提示 “Setup is unable to proceed due tothe follo

CentOS6.9升級autoconf版本,解決”Autoconf version 2.64 or higher is required“錯誤

req higher onf autoconf tex tar ice mail --nodeps 安裝軟件時提示說需要Autoconf 2.64或更高的版本: 1 # autoconf 2 configure.ac:8: error: Autoconf versio

java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.解決辦法

第一次寫部落格,希望大家多多照顧! 這兩天在寫一個springboot的專案,使用了據說是黑馬的HikariCP連線池,配置過程中出現了這個問題,查閱了兩天的資料,終於搞定。 # 配置mysql spri

(親測解決)Unsatisfied dependency expressed through bean property 'sqlSessionFactory'

目錄 一、問題描述     1.使用Maven+SpringBoot+MyBatis測試,啟動專案報錯:Unsatisfied dependency expressed through bean property 'sqlSessionFactory',也就是

解決 Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use

Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use. The server may already be running in ano

Spring註解方式,異常 'sessionFactory' or 'hibernateTemplate' is required解決方法 轉載的,勞記勞記

啟動工程時出現異常: Caused by: java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required       at org.springframewor

CentOS6.5升級autoconf版本,解決”Autoconf version 2.64 or higher is required“錯誤

安裝軟體時提示說需要Autoconf 2.64或更高的版本: [[email protected] wslu]# autoconf configure.ac:8: error: Autoc

You are *required* to use the date.timezone setting or the date_default_timezone_set() function.

2013/09/18 15:23:08 [error] 4023#0: *2 FastCGI sent in stderr: "PHP message: PHP Warning: phpinfo(): It is not safe to rely on the system'

啟動eclipse彈出提示Version 1.7.0_79 of the JVM is not suitable for this product. Version: 1.8 or greater is required怎樣解決

server bubuko 出現 lock http version req program eclipse 啟動eclipse時彈出如下彈出框: 解決辦法: 在eclipse安裝目錄下找到eclipse.ini文件,並在 -vmargs-Dosgi.requiredJ

解決“NOTE: One or more layouts are missing the layout_width or layout_height attributes.”

佈局無法載入,xml也沒有錯誤,提示NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts

解決This function or variable may be unsafe

idt 技術 erro 預處理 管理 復雜 屬性 safe nbsp 當使用VS編寫C/C++時,經常會遇到的一個錯誤是:   error C4996: ‘*****‘: This function or variable may be unsafe.   哎?可我明明使用

maven 下載jar失敗: resolution will not be reattempted until the update interval of central has elapsed or updates are forced

emp 。。 epo except resp esp failure XML could Multiple annotations found at this line: - ArtifactTransferException: Failure to transfer

Version 1.7.0_80 of the JVM is not suitable for this product.Version: 1.8 or greater is required.

2種 方法 mar 技術 bin 啟動 product 分享圖片 1.7 Eclipse啟動失敗,設置eclipse啟動jdk有2種方法 第一種: 直接安裝eclipse對應的jdk版本,並設置環境變量 第二種: 修改eclipse配置文件eclipse.ini