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

时间:2016-12-02 23:39:03

标签: java spring maven dependencies pom.xml

我对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这是有道理的。 org.springframework.transaction确实不存在于存储库中。所以我去了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中看到它们,而不是这个。

3 个答案:

答案 0 :(得分:1)

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

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

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1000 200">
<rect id="border" x="559.5" y="0" width="440.5" height="90" />  
</svg>

答案 1 :(得分:0)

你的.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>
在settings.xml中的

通常位于一个活动的配置文件元素中。  在POM里面就是项目内部。

PS。确保您已连接到存储库URL。如果您在代理后面,则需要在settings.xml中定义它

答案 2 :(得分:0)

正如@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>

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

查看存储库内容

另外要小心,不要首次使用-o标志(或在离线模式下)运行maven,以便让maven下载依赖项。

相关问题