0

I have a maven Spring Boot web application with quite a few (transitive) dependencies.

There are .jar files in the WEB-INF/lib folder inside the built .war.

For example:

  • hibernate-jpa-2.1-api-1.0.0.Final.jar
  • javax.persistence-2.1.0.jar

Both of these contain a class called javax/persistence/JoinColumn.class (with different file sizes).

At runtime, which "version" is going to be referenced when I use it in the code?
Can this type of dependency cause problems later?

  • Yes, they can cause problems (noclassdef, nosuchmethoderror, etc.). How do you avoid this? You locate dependencies supplying the same class and pick one, exclude the other. – ernest_k May 07 '18 at 16:01
  • @w9n7cxx5fM8 the first one Java finds on the classpath. It will cause problems that's for sure. You should be sure about dependencies versions you're using – Dmitry Senkovich May 07 '18 at 16:01
  • The whole point of Spring Boot is that you don't have to worry about dependencies. Could you include your `pom.xml` file? – SeverityOne May 07 '18 at 16:35
  • @ErnestKiwele I can't really exclude the other, because there are some classes which are **only** in one of the `.jar`s. – w9n7cxx5fM8 May 09 '18 at 10:53
  • @w9n7cxx5fM8 If my answer was sufficient, would you mind marking it as Answer? – FrederikVH May 14 '18 at 13:03

1 Answers1

1

To answer your question:

  1. You don't know.
  2. Yes, this will cause problems later.

For a more elaborate answer, check https://stackoverflow.com/a/5474838/7430994

FrederikVH
  • 476
  • 2
  • 8