无法解析依赖项:org.springframework.transaction

Could not resolve dependencies: org.springframework.transaction

我对自己对 Maven 的理解不是很有信心,所以请耐心等待:

我的 POM:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>org.springframework.transaction</artifactId>
  <version>3.2.4.RELEASE</version>
</dependency>

建造:

[WARNING] The POM for org.springframework:org.springframework.transaction:jar:3.2.4.RELEASE is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.427 s
[INFO] Finished at: 2016-12-02T15:22:42-08:00
[INFO] Final Memory: 7M/77M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project PROJECT: Could not resolve dependencies for project PROJECT:jar:1.0: Failure to find org.springframework:org.springframework.transaction:jar:3.2.4.RELEASE in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of maven2 has elapsed or updates are forced -> [Help 1]

查看 http://repo1.maven.org/maven2 this makes sense. org.springframework.transaction is indeed not present in the repository. So I went to this page 并注意到它说工件位于以下存储库中:

https://artifacts.alfresco.com/nexus/content/repositories/public/

这一次,通过存储库,我确实在与我的 POM 中指定的 groupId 和 artifactId 匹配的目录中找到 org.springframework.transaction

https://artifacts.alfresco.com/nexus/content/repositories/public/org/springframework/org.springframework.transaction/

然而这里显然没有3.2.4.RELEASE。我的同事能够构建该项目(尽管他们重新检查它已经有一段时间了)并且他们记得 运行 遇到过类似的问题。虽然我们都是 运行 相同的 POM,但我对为什么这感觉像是一个存储库问题感到有点困惑。

顺便说一句,还有多个其他 org.springframework 依赖项正在正确解析,我可以在我的 ~/.m2 中看到它们,但不是这个。

您的 .m2 没有它,Maven 尝试从定义的存储库中获取它。您没有它们,或者您没有来自 Maven 的连接。 (据我所知,这更有可能是错误所说的)。你在代理后面吗?

您需要定义额外的存储库。在 ~/.m2/settings.xml 或项目级别的 POM 中。

类似的东西:

<repositories>
   <repository>
                <id>fuse-public-repository</id>
                <name>FuseSource Community Release Repository</name>                            
                 <url>https://repo.fusesource.com/nexus/content/groups/public</url>
                <releases>
                    <enabled>true</enabled>
                    <updatePolicy>never</updatePolicy>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                    <updatePolicy>never</updatePolicy>
                </snapshots>
            </repository>
 <repositories>

in settings.xml 通常在活动配置文件元素之一中。 在项目内部的 POM 中。

PS。确保您已连接到存储库 URL。如果你在代理后面,你也需要在 settings.xml

中定义它

org.springframework.transaction 具有 spring-tx 工件 ID。

我在我的 pom 中使用了这个片段并且可以无缝地工作:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>3.2.4.RElEASE</version>
</dependency>

正如@Vadim 刚刚回答的那样,您只需将自定义存储库添加到您的 pom。

<repositories>
    <repository>
      <id>alfresco</id>
      <name>your custom repo</name>
         <url>http://repository.springsource.com/maven/bundles/releas‌​e</url>
    </repository>
</repositories>

然后您可以使用以下方法获取您的依赖项:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>org.springframework.transaction</artifactId>
  <version>3.2.4.RELEASE</version>
</dependency>

您可以使用此 link https://artifacts.alfresco.com/nexus/#nexus-search;quick~transaction

查看存储库内容

同时注意不要运行 maven 第一次使用 -o 标志(或离线模式),以便让 maven 下载依赖项。

最终成为我的 pom.xml 中具有 spring-context 依赖项的问题。显然这对你有用?删除 spring-txorg.springframework.transaction 实际上允许它们被正确下载和访问。