Chinmay
Chinmay

Reputation: 4912

Maven- Significance of ordering of dependencies in POM.xml

What is the significance of dependencies in pom.xml?

I have the dependencies in the following order:

  1. CGLIB
  2. Apache Commons
  3. Spring Data
  4. Hibernate
  5. MySQL Connector
  6. Spring

If I insert Spring Security dependencies above Spring, anywhere, I get errors. For example, if I insert the two dependencies at the very top, I get this exception (also a compiler error before running):

java.lang.NoClassDefFoundError: org/springframework/core/env/EnvironmentCapable

Upvotes: 2

Views: 2706

Answers (1)

Andrey Chaschev
Andrey Chaschev

Reputation: 16526

Dependencies order is insignificant in Maven.

After adding your Spring Security dependencies you need to remove your Spring dependency, because Spring Security references a different version of Spring which does contain this class.

So removing Spring dependency should fix this.

Upvotes: 6

Related Questions