mybatis-spring整合過程當中AbstractMethodError

在整合mybatis和spring的demo中,依賴包均有導入,但控制檯依然有報java.lang.AbstractMethodError的錯誤,剛開始覺得是類型轉換錯誤,仔細看卻發現問題出如今org.mybatis.spring.SqlSession上,具體錯誤以下:java

Exception in thread "main" java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer;
    at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
    at com.sun.proxy.$Proxy0.selectOne(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
    at com.sun.proxy.$Proxy1.findAccountById(Unknown Source)
    at com.frend.Test.main(Test.java:70)
  • 仔細查看後,懷疑是mybatis-spring的包問題,因此直接上官網查詢。
  • 發現官網對mybatis-spring、spring、mybatis三個類型包的版本要求有所說明,具體以下:

(官網連接:http://www.mybatis.org/spring/
mybatis-spring整合過程當中AbstractMethodErrorspring

  • 根據本身的spring和mybatis的版本,我從新下載了mybatis-spring-1.3.0.jar,導入運行,正常
相關文章
相關標籤/搜索