gpt4 book ai didi

java - Spring 依赖

转载 作者:行者123 更新时间:2023-12-04 05:24:38 28 4
gpt4 key购买 nike

我刚刚发现了一件令人生畏的事情。 spring 依赖坐标​​有两个版本。

项目依赖于 spring mvc 和 spring flow。有两组并行的依赖项。

Spring MVC 具有以下方案的依赖项:org.springframework:spring-asm .

Spring Flow 具有以下方案的依赖项:org.springfrmaework:org.springframework.asm .

为什么有两组不同的相同依赖项?如何克服?

<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>org.springframework.webflow</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>


<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>

最佳答案

这基本上是您使用的 Artifact 的问题:

<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>org.springframework.webflow</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>

是来自 SpringSource Enterprise Bundle Repository的 Artifact 并且这些 Artifact 符合 OSGi。我引用:

Welcome to the SpringSource Bundle Repository. Here you'll find OSGi-ready versions of hundreds of open source enterprise libraries that are commonly used when developing Spring applications.



另一方面,你有:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>

是来自 the maven repository 的标准 Artifact .

org.springframework.asm

是用于 OSGi 的 asm Artifact 的修补版本。

解决此问题的最佳解决方案是仅使用 SEBR 存储库 Artifact 。

我推荐这个是因为有一次我遇到了来自 maven 中央仓库的 jar 的问题(它们已损坏),所以我尝试将 SEBR 用于任何 spring 依赖项。但我引用 from the documentation :

If OSGi does not matter to you, either place works, though there are some pros and cons between them. In general, pick one place or the other for your project; do not mix them. This is particularly important since EBR artifacts necessarily use a different naming convention than Maven Central artifacts.

关于java - Spring 依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13334103/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com