I habe the following dependencies within my data module:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm-jakarta</artifactId>
<version>6.1.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-lucene</artifactId>
<version>6.1.7.Final</version>
</dependency>
+ org.hibernate.search:hibernate-search-mapper-orm-jakarta:6.1.7.Final
└── org.hibernate.common:hibernate-commons-annotations:5.1.2.Final
+ org.hibernate:hibernate-core-jakarta:5.6.11.Final
└── org.hibernate.common:hibernate-commons-annotations:5.1.2.Final
+ org.hibernate.search:hibernate-search-mapper-pojo-base:6.1.7.Final
└── org.hibernate.common:hibernate-commons-annotations:5.1.2.Final
+ org.springframework.boot:spring-boot-starter-data-jpa:3.0.5
└── + org.hibernate.orm:hibernate-core:6.1.7.Final
└── org.hibernate.common:hibernate-commons-annotations:6.0.6.Final
The conflict is between hibernate-commons-annotations:5.1.2.Final from hibernate-search-mapper-orm-jakarta and hibernate-commons-annotations:6.0.6.Final from spring-boota-starter-data-jpa dependency.
I want to use hibernate search(with jakarta persistence) and spring boot 3.0.5. How can I achieve this. Can I somehow tell spring to use onother version of hibernate core?
Thanks and Best Regards Matt
You have two alternatives, lifting the hibernate-commons-annotations to 6.0.6.Final or dropping the hibernate-commons-annotations to 5.1.2.Final.
To lift the org.hibernate.search:hibernate-commons-annotations to 6.0.6.Final, simply exclude it from org.hibernate.search:hibernate-search-mapper-orm-jakarta:6.1.7.Final. Then hibernate-search-mapper-orm-jakarta will use the class provided via spring-boot-starter-data-jpa:3.0.5 via hibernate-core:6.1.7.Final
To drop the hibernate-commons-annotations to 5.1.2.Final from the 6.0.6.Final arising from the org.springframework.boot:spring-boot-starter-data-jpa:3.0.5 dependency (which is loading org.hibernate.orm:hibernate-core:6.1.7 & hibernate-commons-annotations:6.0.6.Final) add the following pom dependency:
A possible problem with the second approach is that you lose the intermediate org.hibernate.orm:hibernate-core. It depends on what your code does. If required you can fix by adding the following pom dependency: