I'm using Spring Boot 2.2.5, and pulling in these two artifacts:
spring-boot-starter-test org.hibernate:hibernate-core
When I do this, I end up with duplicate and different classes in jakarta.xml.bind:jakarta.xml.bind-api (v 2.3.2 -- pulled in by spring-boot-starter-test) and javax.xml.bind:jaxb-api (v 2.3.1 -- pulled in by hibernate-core). I'm letting spring boot manage all versions, including hibernate-core.
Comment From: foxdk
Here is the output from mvn dependency:tree deps2.2.5.txt
Comment From: wilkinsona
Thanks for the report. You aren't using Spring Boot's Data JPA starter so you've lost Spring Boot's opinion that javax.xml.bind:jaxb-api
should be excluded:
https://github.com/spring-projects/spring-boot/blob/9e7ab46eccf31a1e91205808dcb08e4bb5147096/spring-boot-project/spring-boot-starters/spring-boot-starter-data-jpa/pom.xml#L58-L61
We can't include that opinion in Spring Boot dependencies as it may be too broadly applied in that case. There's no 2.3.2 version of javax.xml.bind:jaxb-api
so aligning the versions is not possible and we can't tell Maven to substitute one for the other as it does not provide a way for us to do so.
In short, you can avoid this problem by making broader use of Spring Boot's starters. If you're not in a position to do that, you will have to configure some exclusions yourself.