MOYUN(/Java/SQL/Linux/DevOps/运维/架构/管理/敏捷/开发)

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

在MAVEN项目里面,在整合spring和mybatis在执行数据库操作的时候报出了:

java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()L错误

在网上搜的大多说是jar包版本不兼容的问题。但想想,不应该啊,这是他们原有的系统,难道有做过升级吗,最后尝试着把版本升级了下,还真是版本兼容出了问题。

 1 Exception in thread "main" java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer;
 2 at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85)
 3 at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
 4 at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
 5 at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
 6 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
 7 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
 8 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
 9 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
10 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
11 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
13 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
14 at java.lang.reflect.Method.invoke(Unknown Source)
15 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
16 at com.sun.proxy.$Proxy8.selectOne(Unknown Source)


更正后的依赖关系为:

<properties>
    <springframework.version>3.2.9.RELEASE</springframework.version>
    <mybatis-spring.version>1.3.0</mybatis-spring.version>
    <mybatis.version>3.3.0</mybatis.version>
    <mysql-connector-java.version>5.1.37</mysql-connector-java.version>
</properties>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>${mybatis-spring.version}</version>
</dependency>

大致导致这个问题的原意就是版本的问题, 将上面的mybatis-spring版本改为1.3.0即可.具体细节还有待去发现,

可参考http://www.mybatis.org/spring/zh/

 

posted on 2016-11-12 11:25  moyun-  阅读(32481)  评论(0编辑  收藏  举报