Is Mybatis supported with Spring 4.x? - spring

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)

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.

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.

Related

Why is my H2 database Spring config not working?

I am always getting java.lang.NoSuchMethodError: org.springframework.orm.jpa.JpaTransactionManager$JpaTransactionObject.setReadOnly(Z)V
I do not know why.
I use H2 database in memory. According to spring there is no configuration necessary. I just include the dependency in my maven POM . But when I call the database it gives me this error.
public interface ClientRepository extends CrudRepository<Client, Long> {
I know a lot had this error before but I cannot see any mistake on my side. According to spring it should work out of the box. Just add maven dependency. Nothing more. So where is my error.
It seems that if you mix Spring boot dependencies and Spring framework dependencies maybe this could cause a problem. I really do not know. I removed this dependency
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
It was not Spring boot . So I would not need it anyway. I think Spring boot will never ever need any Spring framework dependency I guess.
Also versions could maybe be an issue. I did not include any version. Because Spring boot should then just take the latest one. Right ? But now I have versions. Maybe this was also an issue.

Which version is compatible with which? Spring and JSTL

I am new to Maven. Now, in my POM, I declared I need Spring 3.0.5.RELEASE. After I started my server and tried to access a page, the server threw a java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config error.
Now after researching online, I found that I need to include a JSTL dependency like so:
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
I have faced this question multiple times. How do I know which version of jstl is comptabile with Spring 3.0.5.RELEASE
I know this might be a basic question but it will help everyone
You could also try generating a Spring Boot Maven project via http://start.spring.io/ rather then manually setting one up.

Error when creating new Spring MVC project in IntelliJ: invalid item 'Maven: org.springframework:spring-test-mvc:1.0.0.M2

Using IntelliJ IDEA 13.1.4 to create a new project with Spring MVC and "Create project from template" checked, I get the error message below in the project structure.
Anyone know why, and whether I should worry about it?
Module 'Test': invalid item 'Maven: org.springframework:spring-test-mvc:1.0.0.M2' in the dependencies list
Hmm... What version of Spring is the template project using?
From Spring 3.2 and onwards the spring-test-mvc dependency was merged into spring-test dependency.
So for anything using Spring 3.2 onwards you only need:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
Also, It might be worth looking at the Spring platform-bom

Issue while adding commons validator dependency in pom.xml of Spring 3.1 project

In my project, which is being developed in Spring 3.1, I am trying to perform both client side and server side validations by making use of Apache Commons Validator. But just by adding the below mentioned code is causing some xml exception.
added dependency in pom.xml: -
<dependency>
<groupId>org.springmodules</groupId>
<artifactId>spring-modules-validation</artifactId>
<version>0.8</version>
</dependency>
compile time exception in servlet-context.xml --> Resource Path Location Type Referenced file contains errors (jar:file:/C:/Users/shift/.m2/repository/org/springframework/spring-beans/3.1.0.RELEASE/spring-beans-3.1.0.RELEASE.jar!/org/springframework/beans/factory/xml/spring-beans-3.0.xsd).
I read somewhere that the jars of Spring 3.1 might be colliding with Spring 2.x (which is added in maven repository as [i]spring-modules-validation[/i] brings it with it). After that I added an exclusion as mentioned below: -
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
After which the exception disappeared but inbuilt classes like InternalResourceViewResolver, DataSourceTransactionManager, etc. are not found by the compiler.
Is there something else which I have missed, or any other way apart from Commons Validator to perform client and server side validations in Spring 3.1 ?

What is the purpose of using Spring-orm?

I have the following maven dependency in my project.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>2.5.6</version>
</dependency>
We are using iBatis for ORM.
What is the purpose of giving this dependency?
Is this required if I to have bridge between Spring and iBatis?
In general how Spring and iBatis linked?
Thanks for your response.
What is the purpose of giving this dependency?
Is this required if I to have bridge between Spring and iBatis?
It adds support (glue code) to integrate various ORM solutions with Spring, including Hibernate 3/4, iBatis, JDO and JPA. Of course it's not an ORM on its own, it's just a bridge. You still need to include relevant libraries.
In general how Spring and iBatis linked?
Quoting official documentation: 12.5. iBATIS SQL Maps:
iBATIS support works with Spring's exception hierarchy and let's you enjoy the all IoC features Spring has.
Transaction management can be handled through Spring's standard facilities.

Resources