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.
Related
I have a simple springboot application which uses H2 in memory db. I have used following dependency in my POM
spring-boot-starter-data-jpa
com.h2database.h2
When I start application, It automatically create Entity tables using Hibernate Dialect. I have no where mentioned about Hibernate in my POM. So why does this happening. Why Spring is using Hibernate Dialect. Do we have any option to change this dialect to some other dialect. please help.
Starter poms in the SpringBoot ecosystem bring a bag of dependencies, which have been tested and are proven to work together. It also saves you the hustle of managing the right dependencies versions.
You're using spring-boot-starter-data-jpa - which is a starter pom for JPA - the opinionated choice here is the usage of Hiberante as JPA provider.
If you look at the source of the pom file, you will see this definition:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
This is what brings hibernate to your project, although you have not explicitly declared it in your pom. The hibernate is downloaded as implicit dependency because of your spring-boot-starter-data-jpa starter pom.
Well you using "spring-boot-starter-data-jpa" and "starter" notion means that it has everythingfor it to work. If you would look to https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa/2.1.3.RELEASE , this dependency also includes hibernate-core.
I am trying to learn Spring AOP programming using Spring 5. I am going through online materials.
I came to know that AOP is a concept, similar to OOP; and with AOP,OOPs becomes more powerful.
Now, I am trying to do some hands-on coding for AOP with Spring framework, version 5.
I am going to use maven as the build tool.
I am not clear on what are the various dependencies that we have to use in pom.xml, for example do we need to use: spring-aop , spring-aspects, aspectjetc.
Can anyone guide me what are the various maven dependencies that we have to add in pom.xml to be able to write using maven tool, Spring 5 AOP programs?
Thanks in advance
Its very simple, in order to work spring With AOP, You need aspectjweaver Library existe on the classpath of your application (version 1.6.8 or later).use this dependency to achieve that
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.13</version>
</dependency>
As they mention in docs
To enable #AspectJ support with Java #Configuration add the
#EnableAspectJAutoProxy annotation:
You can find more info here
The only spring dependency to make something work with AOP is the famous spring-context :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
If you want a working example check my project in github which contains basic Maven AOP example based on spring
If you are trying to use CGLIB proxies in Spring without Spring Boot (and any starter dependencies of Spring Boot) then you need aspectjweaver besides spring-context, spring-aop dependencies.
Be careful not to add any of the dependencies if they already exist among your Maven dependencies - adding the same dependency with multiple versions may lead to a failing build.
I am pretty new in JPA\Hibernate and I have the following doubt.
Into the pom.xml file of a Spring MVC projet I found the following dependency that are added to my project (that use JPA to implement my repository).
<dependencies>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.11.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.8.2.RELEASE</version>
</dependency>
</dependencies>
So I am trying to understand the architecture of this projet and what exactly does these dependendency.
So from what I know JPA is only a specification and I can't use it without an implementation. So is JPA something like a set of interface that specify what operation I can perform and then I need something that implement that operation?
1) So, from what I have understand, the first artifact (the hibernate-jpa-2.1-api) should be the JPA specification.
Here the structure documentation: https://docs.jboss.org/hibernate/jpa/2.1/api/ and infact looking into the listed package it seems to me that are almost interfaces but not implementation classes.
If this assertion is correct my doubt is: why if it is the JPA specification it is provided under hibernate that should be an implementation o this specification? (Exist different version of the JPA spcificication or is it unique?)
2) The hibernate-core artifact should be the JPA implementation (from what I know exist various implementation and Hibernate is one of these, another one is EclipseLink and so on). So this artifact provide me the tool that allows me to interact concretely with the database)
3) The spring-data-jpa is a part of the Spring Data that make easier create JPA repository (for example allow me to use the "Specification" concept to create query)
Is it my reasoning correct or am I missing something?
JPA is just annotations (kind of interfaces) you can use to mark your class Entities and relations. Later you can use Hibernate (or EclipseLink) as implementation of the JPA.
Thus you can change implementation leaving annotations (interfaces).
Check also this
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.
I have the following maven dependecy in my project.
<dependency>
<groupId>org.jvnet.jax-ws-commons.spring</groupId>
<artifactId>jaxws-spring</artifactId>
<version>1.8</version>
</dependency>
Question:
Is this Spring Webservices project?
If not what this dependency is for?
Thanks for your help.
It's a project combining JAX-WS and Spring. Basically it gives you the wss namespace that you might be using in your application context to expose JAX-WS providers as web services. It isn't mandatory but it can be a convenience as it allows you to easily have dependency injection in your servlets although there are other ways to get this. Unfortunately, the last time I was using it I noticed that it was depending on some pretty old spring libraries (pre 3.x) and didn't seem to be updated in some time.