0

我使用以下站点创建了一个 Maven Web 项目。

http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/

我已经执行了那里给出的所有步骤并执行了一个简单的 hello world 程序。现在,我必须将 spring 依赖项包含到我的 eclipse web 项目中。

所以

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>3.1.2</version>
</dependency>

在依赖项标签中,我添加了上述配置。现在,它是这样说的:

unable to find jars from the repositories (local and as well as remote)

它给出了执行命令的建议:

mvn install -artifactid=springframework   (something like this)

但是当我提到版本为 2.5.6 时,它是正确的。maven存储库中版本3.1.2不可用的问题吗?如果 maven 对于最新版本不能正常工作,我如何获得最新版本?

它还给了我手动下载并放入本地存储库的建议。

4

1 回答 1

1

Maven 坐标随时间而变化。

尝试:

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.core</artifactId>
        <version>3.1.2.RELEASE</version>
</dependency>

或尝试:

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.1.2.RELEASE</version>
</dependency>

我会发现是否存在一体化 POM 或依赖项。但是“spring-full”看起来只有 1.2.x 而“spring”看起来是 2.5.x。已检查:找不到一个我一直在所有项目中使用单独的模块一段时间(无论如何这更好,细粒度的依赖项)。

您可以搜索的位置是http://ebr.springsource.com/repository/app/

对于 3.1.2,请参阅http://ebr.springsource.com/repository/app/library/version/detail?name=org.springframework.spring&version=3.1.2.RELEASE&searchType=librariesByName&searchQuery=spring

据我所知,在过去的 4 年中,Spring 至少 3 次更改了他们的存储库 URL 和在线位置。因此,我会在他们的网站上查找有关设置 Maven<repositories>配置以获取其 JAR 的当前信息。谨防信息过时的文章:(

还要注意 2 示例中的 artifactId 不同,这是 spring 的另一个问题。“org.springframework.core”是他们软件的 EBR 和 OSGi 兼容版本。“spring-core”是旧的 pre-OSGi 坐标。找到适合你的方法,不要将它们混在同一个项目中。例如,我使用的是“spring-core”,因为我使用的是里程碑版本的 3.2.0.M2。但是生产版本的 EBR 坐标是最好用的。

很抱歉进行了如此多的编辑……但即使您了解获取 Spring Source 软件的传统,这也是一个雷区。

于 2012-09-22T09:26:32.047 回答