1

I upgraded from springboot 2.7.6 to springboot 3.0.0;I have a maven based multi module project

In my main module I have:

<dependencyManagement>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-dependencies</artifactId>
      <version>3.0.0</version>
      <type>pom</type>
      <scope>import</scope>
   </dependency>
</dependencyManagement>

In one of my module I need to use jaxb. So I added in my module the following:

<dependency>
   <groupId>org.glassfish.jaxb</groupId>
   <artifactId>jaxb-runtime</artifactId>
</dependency>

As far as I understood by reading here https://docs.spring.io/spring-boot/docs/3.0.0/reference/htmlsingle/#appendix.dependency-versions in my child module I should have the version 4.0.1 of jaxb-runtime but, by seeing the dependency tree I see the versione 2.3.5. Any idea?

Always related to this, it seems that some libraries are not inherited by sub-module. In my maven dependencyManagement tag I had to add:

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-oauth2-client</artifactId>
    <version>6.0.0</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>4.0.1</version>
</dependency>
<dependency>
    <groupId>org.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>3.10.8</version>
</dependency>
<dependency>
    <groupId>jakarta.validation</groupId>
    <artifactId>jakarta.validation-api</artifactId>
    <version>3.0.2</version>
</dependency>

With the previous version of springboot (2.7.6) all worked pretty good and I had to add none of the previous dependencies. All of them were inherited by spring boot bom

Do you have any tip or suggestion?

Thank you

Angelo

UPDATE MAVEN VERSION

This is my environment:

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /home/angelo/apache-maven
Java version: 17.0.1, vendor: Oracle Corporation, runtime: /usr/lib/jvm/jdk-17.0.1
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-56-generic", arch: "amd64", family: "unix"
Brian Clozel
  • 56,583
  • 15
  • 167
  • 176
Angelo Immediata
  • 6,635
  • 4
  • 33
  • 65
  • 1
    Checking the easy things first... did you remember to `mvn clean install` the parent POM after changing to use the updated Spring Boot? – user944849 Dec 06 '22 at 16:14
  • Look at the dependency tree when you don't force the version to 4.0.1: you'll see what other dependency pulls 2.3.5 first. I love the maven plugin for Eclipse "Dependency Hierarchy" tab when I need to understand resolved dependency versions. (first comment is smart, also "refresh" maven project in your IDE to force it load new dependencies) – ch4mp Dec 06 '22 at 16:16
  • 1
    @user944849 I always execute clean install from the top – Angelo Immediata Dec 06 '22 at 16:25
  • @ch4mp I'm using a similar plugin in intellij; honestly I directly added the dependency (before to "force" in dependencyManagement) and i don't understand who is loading the 2.3.5 but it seems derived by springboot – Angelo Immediata Dec 06 '22 at 16:26
  • That's my point with the eclipse plugin: I don't have to "understand", I just "read" how a dependency is resolved – ch4mp Dec 06 '22 at 16:30
  • Okay, next step - is the "top" POM both a parent and an aggregator? If so, you may be running into something like [this](https://stackoverflow.com/a/21590120/944849). I would doublecheck that the POM is actually being upgraded. Again, in the spirit of checking easier things first. – user944849 Dec 06 '22 at 16:54
  • @user944849 I divided the aggregator pom from the parent pom. Well if i delete the ehcache version maven doesn't compile because ehcache version is missing. But from springboot 3 reference it should be inherited by spring dependencies. I really don't understand this behavior – Angelo Immediata Dec 06 '22 at 17:29
  • What version of Maven are you running? And, are you running Maven from IDE or command line? If IDE... try command line. Let's get the IDE out of the picture. – user944849 Dec 06 '22 at 18:27
  • If you upgrade such cases always read the upgrade guides https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Release-Notes ehcache version 3.10.X is used and furthermore javax is replaced with jakarta.. instead... etc. Please check the upgrade guides in the release notes!! – khmarbaise Dec 06 '22 at 22:43
  • @user944849 I'm using maven 3.8.6, JDK 17 (I updated my question with the info). The "issue" happens both by using command line and IDE (I configured my IDEs in order to use my own maven installed externally to the IDE) – Angelo Immediata Dec 07 '22 at 08:43
  • @khmarbaise I honestly don't understand your answer about the release notes and so. I read them and in springboot documentation it's written we can use ehcache 3.10.8. All javax imports have been replaced with jakarta. The "issue" (if we want to call it so) is related to the fact that some libraries version I expect inherited by springboot deps are not inherited and i need to write the version manually – Angelo Immediata Dec 07 '22 at 08:46
  • And which libraries are you talking about? – khmarbaise Dec 07 '22 at 09:59
  • @khmarbaise just the ones i indicated in the post, that is spring-security-oauth2-client, jaxb-runtime, jakarta.validation-api and ehcache. If I don't specify the version i see old versions of these jars. Note: with ehcache it's also worse... without version maven complains because no version is specified – Angelo Immediata Dec 07 '22 at 10:35

1 Answers1

1

I think you'll need to carefully review your dependencies. You should as much as possible avoid using <version> tags if those versions are managed by the Spring Boot dependency management.

In your case, I think your ehcache dependency is missing the jakarta classifier.

<dependency>
  <groupId>org.ehcache</groupId>
  <artifactId>ehcache</artifactId>
  <classifier>jakarta</classifier>
</dependency>
Brian Clozel
  • 56,583
  • 15
  • 167
  • 176
  • 1
    I tried several solution, included the classifier. I get this error [ERROR] 'dependencies.dependency.version' for org.ehcache:ehcache:jar is missing. @ line 302. Moreover I totally agree to avoid version – Angelo Immediata Dec 22 '22 at 10:55
  • Maybe this is about the ordering of those dependencies declaration? I've created a sample application on start.spring.io, added the ehcache dependency and built the application successfully. So there must be something else specific to your case. – Brian Clozel Dec 22 '22 at 14:02
  • that's strange... till spring boot 2.7.6 i didn't need to add versions... During the Christmas vacations I'll deeply dig. Now I'm curious and I want to understand – Angelo Immediata Dec 22 '22 at 15:27