2013-05-13 379 views
0

我是Spring的新手,我将在春季开发我的第一个Helloworld应用程序。 我用什么Spring依赖关系解析

春2.5.6

JDK 1.7

的Eclipse 3.6

Maven的

我下载Spring框架,并添加所需的所有罐子对我的项目但当我添加依赖我的pom.xml文件,并尝试建立它给了我下面的错误该项目

Could not resolve dependencies for Project.... 

我的pom.xml的是

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
<modelVersion>4.0.0</modelVersion> 

<groupId>de.tum.ibis.wsc</groupId> 
<artifactId>SpringHelloWorld</artifactId> 

<packaging>war</packaging> 
<version>0.0.1-SNAPSHOT</version> 
<name>Web Services Computing</name> 
<url>http://dss.in.tum.de</url> 

<properties> 
    <output.filename>hello</output.filename> 
</properties> 

<!-- //////////////////////////////////////////////////////////// --> 
<!-- //////////////////////////////////////////////////////////// --> 
<!-- /////////// DEPENDENCIES --> 

<dependencies> 

<!-- Spring framework --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring</artifactId> 
     <version>2.5.6</version> 
    </dependency> 

    <!-- Spring MVC framework --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>2.5.6</version> 
    </dependency> 

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

    <!-- JUnit to run the tests --> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.10</version> 
     <scope>test</scope> 
    </dependency> 

    <!-- Java servlet API --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>2.5</version> 
    </dependency> 

    <!-- Velocity templating engine --> 
    <dependency> 
     <groupId>org.apache.velocity</groupId> 
     <artifactId>velocity</artifactId> 
     <version>1.7</version> 
    </dependency> 

    <!-- JSTL --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>jstl</artifactId> 
     <version>1.2</version> 
    </dependency> 

    <!-- langCommons --> 
    <dependency> 
     <groupId>org.apache.commons</groupId> 
     <artifactId>commons-lang3</artifactId> 
     <version>3.0.1</version> 
    </dependency> 

</dependencies> 

<pluginRepositories> 
    <pluginRepository> 
     <id>codehaus-snapshots</id> 
     <name>Codehaus Snapshots</name> 
     <url>http://nexus.codehaus.org/snapshots/</url> 
     <releases> 
      <enabled>false</enabled> 
     </releases> 
     <snapshots> 
      <enabled>true</enabled> 
     </snapshots> 
    </pluginRepository> 
</pluginRepositories> 

<repositories> 
    <repository> 
     <id>codehaus-snapshots</id> 
     <name>Codehaus Snapshots</name> 
     <url>http://nexus.codehaus.org/snapshots/</url> 
     <releases> 
      <enabled>false</enabled> 
     </releases> 
     <snapshots> 
      <enabled>true</enabled> 
     </snapshots> 
    </repository> 
</repositories> 


<!-- build configuration --> 
<build> 
    <finalName>${output.filename}</finalName> 

    <plugins> 
     <!-- CARGO plugin to start an embedded Jetty for testing --> 
     <plugin> 
      <groupId>org.codehaus.cargo</groupId> 
      <artifactId>cargo-maven2-plugin</artifactId> 
      <version>1.2.4</version> 

      <configuration> 
       <container> 
        <containerId>jetty7x</containerId> 
        <type>embedded</type> 
       </container> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

Maven的输出:

[INFO] ------------------------------------------------------------------------ 
Downloading:  http://repo.maven.apache.org/maven2/org/springframework/spring/2.5.6/spring-2.5.6.pom 
Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring- webmvc/2.5.6/spring-webmvc-2.5.6.pom 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 21.301s 
[INFO] Finished at: Mon May 13 14:42:03 CEST 2013 
[INFO] Final Memory: 3M/15M 
[INFO] ------------------------------------------------------------------------ 
[WARNING] The requested profile "local" could not be activated because it does not exist. 
[ERROR] Failed to execute goal on project SpringHelloWorld: Could not resolve dependencies for project de.tum.ibis.wsc:SpringHelloWorld:war:0.0.1-SNAPSHOT: Failed to collect dependencies for [org.springframework:spring:jar:2.5.6 (compile), org.springframework:spring-webmvc:jar:2.5.6 (compile), junit:junit:jar:4.10 (test), javax.servlet:servlet-api:jar:2.5 (compile), org.apache.velocity:velocity:jar:1.7 (compile), javax.servlet:jstl:jar:1.2 (compile), org.apache.commons:commons-lang3:jar:3.0.1 (compile)]: Failed to read artifact descriptor for org.springframework:spring:jar:2.5.6: Could not transfer artifact org.springframework:spring:pom:2.5.6 from/to central (http://repo.maven.apache.org/maven2): connection timed out to http://repo.maven.apache.org/maven2/org/springframework/spring/2.5.6/spring-2.5.6.pom -> [Help 1] 

    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
    [ERROR] Re-run Maven using the -X switch to enable full debug logging. 
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles: 
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException 

任何想法为什么我得到这个错误?

在此先感谢

+0

maven输出是否告诉你哪些依赖项丢失?你是否100%确定他们在你使用的回购站?你可以发布一些更多的Maven输出吗? – 2013-05-13 13:03:09

+0

@leo检查我的更新 – Wearybands 2013-05-13 13:07:16

+0

你如何运行你的maven?你是否支持代理? – acdcjunior 2013-05-13 13:08:25

回答

0

按照MVN输出行家不能取“http://repo.maven.apache.org/maven2/org/springframework/spring/2.5.6/spring-2.5.6.pom”。

但是,我现在可以用我的浏览器来获取它。 这样的事情可能是由网络/代理问题引起的。

如果你的maven/proxying/dns配置没有任何问题,我试图用替代回购来解决dep的问题。 像这样,例如:https://repository.jboss.org/nexus/index.html#welcome

此外,如果您想尝试替代回购,这可能很方便。这里是我的一个项目的存储库部分的复制粘贴:

<repositories> 

    <repository> 
     <snapshots> 
      <enabled>false</enabled> 
     </snapshots> 
     <id>JBossCommunity_Releases</id> 
     <name>Releases Repository Group</name> 
     <url>https://repository.jboss.org/nexus/content/repositories/releases</url> 
    </repository> 

    <repository> 
     <snapshots> 
      <enabled>false</enabled> 
     </snapshots> 
     <id>JBossCommunity_Public</id> 
     <name>Public Repository Group</name> 
     <url>https://repository.jboss.org/nexus/content/repositories/public</url> 
    </repository> 

    <repository> 
     <id>spring-maven-release</id> 
     <name>Spring Maven Release Repository</name> 
     <url>http://maven.springframework.org/release</url> 
    </repository> 

    <repository> 
     <id>spring-maven-milestone</id> 
     <name>Spring Maven Milestone Repository</name> 
     <url>http://maven.springframework.org/milestone</url> 
    </repository> 

</repositories> 
+0

你是什么意思的替代回购? – Wearybands 2013-05-14 15:10:34

+0

工件(这种情况下的依赖瓶)来自maven仓库。除了违约,“中央”回购以来,各方都维护了这些回购。那就是我的意思是“替代回购”。 我们甚至有我们自己的内部回购,曾经托管过我们家酿的一些罐子,没什么特别。 ... – 2013-05-15 08:52:55

+0

...根据你的pom.xml你已经使用codehouse回购。我发布了一个来自我们的工作项目的复制粘贴,它使用由spring和jboss社区维护的回购站。由于你的构建不能解决与春天有关的工件,所以maven很有可能从spring家伙自己维护的回购库中获取它。 – 2013-05-15 08:53:12