简体   繁体   English

Maven- POM.xml中依赖项排序的意义

[英]Maven- Significance of ordering of dependencies in POM.xml

What is the significance of dependencies in pom.xml? pom.xml中的依赖关系有何意义?

I have the dependencies in the following order: 我具有以下顺序的依赖项:

  1. CGLIB CGLIB
  2. Apache Commons Apache Commons
  3. Spring Data 春季数据
  4. Hibernate 过冬
  5. MySQL Connector MySQL连接器
  6. Spring 弹簧

If I insert Spring Security dependencies above Spring, anywhere, I get errors. 如果我在任何地方都在Spring之上插入Spring Security依赖项,则会出现错误。 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 java.lang.NoClassDefFoundError:org / springframework / core / env / EnvironmentCapable

Dependencies order is insignificant in Maven. 依赖关系顺序在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. 添加Spring Security依赖项后,您需要删除Spring依赖项,因为Spring Security引用了包含此类的Spring的不同版本。

So removing Spring dependency should fix this. 因此,删除Spring依赖项应该可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM