Is Mybatis supported with Spring 4.x?

安稳与你 提交于 2019-12-10 19:39:27

问题


I tried mybatis-spring 1.2.2 with mybatis 3.2.5 and Spring version 4.1.0.Release and it appears like it is not supported.

mybatis-spring 1.2.2 spring contains org.springframework.core.MethodParameter class however, getContainingClass() is not present.

I am getting the exception: java.lang.NoSuchMethodError: org.springframework.core.MethodParameter.getContainingClass()

Any idea is I could use Mybatis with Spring 4x at all? (even ibatis seems to be unsupported)


回答1:


Looking in the pom.xml of the Spring MyBatis here I can see that the project itself depends on Spring 3.2.9:

...
<spring.version>3.2.9.RELEASE</spring.version>
...
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>${spring.version}</version>
  <scope>provided</scope>
</dependency>

So, based on that I wouldn't be surprised if I would get an exception like the one you are getting in my project and I would have to say that "no", it's not supported.




回答2:


We are using MyBatis v3.2.7 with Spring v4.0.6 and so far we have not seen any issues. Since Spring usually maintains the backward compatibility, it usually works.

However, I am not sure (as of this writing) if it is totally supported in Spring v4.1.x.



来源:https://stackoverflow.com/questions/25047736/is-mybatis-supported-with-spring-4-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!