2

I am facing difficulty for dependencies related issue like:

I have created a spring project in 4.1.1.RELEASE version. Now i want to use hibernate dependency for spring version 4.1.1.RELEASE.

But which version of hibernate dependency is compatible with above version of spring? Is there any site for compatibility checking or anything else? Please help me

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
Md. Naushad Alam
  • 8,011
  • 6
  • 25
  • 23

2 Answers2

3

You can simply run:

mvn dependency:tree

And then look for org.hiberante dependencies inherited from the spring modules. That's how you can tell which Spring version uses a certain Hibernate dependency.

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
  • After running this command "mvn dependency:tree" in project directory it's getting error. – Md. Naushad Alam Apr 28 '15 at 10:07
  • Here is the error............... [ERROR] Could not find goal '' in plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 among available goals copy, analyze, unpack, list-repositories, resolve, resolve-plugins , build-classpath, list, analyze-dep-mgt, sources, analyze-duplicate, copy-dependencies, unpack-dependencies, go-offline, get, purge-local-repository, properties, analyze-report, tre e, analyze-only, help -> [Help 1] – Md. Naushad Alam Apr 28 '15 at 10:16
  • ya but if you have transitive dependencies you can exclude and exclude and exclude until you get to the root dependency you're looking for – mdo123 Jun 16 '17 at 17:13
2

I recommend to use the same versions that are used by Spring Boot. (I do not mean that you should use Spring-Boot, just use the same set of dependencies/versions).

Spring Boot has some kind ob BOM-depencency, that contains the dependencies:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>1.2.3.RELEASE</version>
</dependency>

The current version of spring-boot: 1.2.3.RELEASE uses Spring 4.1.6.RELEASE, so you must maybe search for one boot that is a bit older.

Even Spring-Boot 1.2.0.RELEASE use Spring 4.1.3.RELEASE - so you Either update to Spring >= 4.1.3. or you ignore this version mismatch.

After you have chosen the rigth Spring-Boot Version: You either check out this file and search for the version number you need, or you import it in to your pom.xml, and the omit the explicit version attribute in your hibernate-dependency>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.2.3.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement> 
...
<dependencies>
    <dependency>     
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <!-- version is taken from the bom -->
    </dependency>
</dependencies>
Community
  • 1
  • 1
Ralph
  • 118,862
  • 56
  • 287
  • 383
  • How do i know which version of Spring-Boot support 4.1.1.RELEASE version of spring? – Md. Naushad Alam Apr 28 '15 at 09:44
  • 1
    Go to Maven-Central: search for spring-boot-dependencies, open the pom for 1.2.3, 1.2.2. 1.2.1, 1.2.0 (...), search within the pom for: `` – Ralph Apr 28 '15 at 09:48
  • Even Spring-Boot 1.2.0.RELEASE use Spring 4.1.3.RELEASE - so you Either update to Spring >= 4.1.3. or you ignore this version mismatch. – Ralph Apr 28 '15 at 09:52
  • The Spring-Boot uses 4.0.9.RELEASE or 4.1.3.RELEASE but not 4.1.1.RELEASE version. Why spring 4.1.1.RELEASE version not exist in spring-boot? – Md. Naushad Alam Apr 28 '15 at 10:01
  • Can i ask you one more question? – Md. Naushad Alam Apr 28 '15 at 10:22
  • 1
    Spring-Boot and Spring(core) are two asynchronous projects - so there is no Boot for each Spring(core) – Ralph Apr 28 '15 at 10:48
  • you can use springs bom instead of spring boots, https://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#overview-maven-bom – mdo123 Jun 16 '17 at 17:16
  • @mdo: the spring-framework-bom contains only spring-framework modues (spring-beans, spring-context, spring-web, spring-test, spring-orm...) but does not contain references for hibernate or any libary other than spring. – Ralph Jun 19 '17 at 08:14
  • What did they do before Spring Boot? Why don't they simply have a webpage showing which versions are compatible? That would be much easier than searching maven central and reading POMs. – Philip Rego May 10 '19 at 21:07