Java 需要 Spring 版本# - 只有 spring.jar 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/947586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 21:25:12  来源:igfitidea点击:

Need Spring version# - only have spring.jar file

javaspring

提问by Gary Kephart

I've inherited an app that uses Spring. The original developers are not available. The Spring jar file is just "spring.jar", so there's no version# in the filename to help me. I'd like to download the Spring source corresponding to the jar file. The MANIFEST.MF file has "Spring-Version: 1.2" however that's not precise enough. I've looked at version 1.2.1 and 1.2.9 and it doesn't match up quite right. The key thing is that org.springframework.web.servlet.view.AbstractCachingViewResolverhas a prepareViewmethod which is called from resolveViewNameand it does not seem to be in 1.2.1 or 1.2.9.

我继承了一个使用 Spring 的应用程序。原始开发人员不可用。Spring jar 文件只是“spring.jar”,因此文件名中没有 version# 可以帮助我。我想下载jar文件对应的Spring源码。MANIFEST.MF 文件有“Spring-Version: 1.2”,但这不够精确。我查看了 1.2.1 和 1.2.9 版本,但它们不太匹配。关键是它org.springframework.web.servlet.view.AbstractCachingViewResolver有一个prepareView被调用的方法,resolveViewName它似乎不在 1.2.1 或 1.2.9 中。

Is there any easy way to track down the right version?

有什么简单的方法可以找到正确的版本吗?

采纳答案by duffymo

This will do it:

这将做到:

import org.springframework.core.SpringVersion;

public class VersionChecker
{
    public static void main(String [] args)
    {
        System.out.println("version: " + SpringVersion.getVersion());
    }
}

Compile and run this with spring.jar in your CLASSPATH and it'll display the version for you. See the javadocsas well.

使用 CLASSPATH 中的 spring.jar 编译并运行它,它会为您显示版本。另请参阅javadoc

回答by Gary Kephart

How about checksumming the JAR file and comparing it to the spring.jar files in the distributions from SpringSource? Might take an hour or so to do the downloads, but it should be definitive.

如何校验 JAR 文件并将其与 SpringSource 发行版中的 spring.jar 文件进行比较?下载可能需要一个小时左右,但它应该是确定的。

回答by victor hugo

According to mvnrepository.com1.2.9 weights 2.2MB and 1.2.1 weights 2.0MB, that page also has a link for downloading both. I think the weight difference is enough for comparing the files. If you can't see the difference just checksum. If you can't see a relation neither with 1.2.1 nor 1.2.9 you can use the page to download any other version quickly (I use it often)

根据mvnrepository.com1.2.9 权重 2.2MB 和 1.2.1 权重 2.0MB,该页面还有一个下载链接。我认为重量差异足以比较文件。如果您看不到差异,只需校验和。如果您看不到与 1.2.1 或 1.2.9 的关系,您可以使用该页面快速下载任何其他版本(我经常使用它)

NOTE: If your JAR is below 2.0MB then I'm afraid duffymo has reason and your JAR is 1.2

注意:如果您的 JAR 低于 2.0MB,那么恐怕 duffymo 是有原因的,而您的 JAR 是 1.2

回答by Michael Wiles

You can try looking inside the jar's MANIFEST.MF in the META-INF directory - it should indicate what version yo're working with.

您可以尝试在 META-INF 目录中查看 jar 的 MANIFEST.MF - 它应该指示您正在使用的版本。

回答by vehnae

The really easy way is to get the MD5 sum of the archive and google it. Many sites that store .jar archives also index the MD5 sums which Google then finds easily. This works really well for pretty much any Java components.

真正简单的方法是获取存档的 MD5 总和并在 google 上搜索。许多存储 .jar 档案的站点也会索引 MD5 总和,然后 Google 很容易找到这些总和。这对于几乎所有 Java 组件都非常有效。

$ md5sum spring-2.5.5.jar
82a2134b227f717066da4f4b059925d3

http://www.google.com/search?q=82a2134b227f717066da4f4b059925d3

http://www.google.com/search?q=82a2134b227f717066da4f4b059925d3

回答by misterGrosar

You cann check it in pom.xml file in <org.springframework-version>tag.

您可以在<org.springframework-version>标记中的 pom.xml 文件中检查它。

回答by shaik rizwan

go to MATA-INF directory and open manifest file.It will be there what version you are using.

转到 MATA-INF 目录并打开清单文件。它将显示您正在使用的版本。