2013-03-18 46 views
2

我只是想試試Spray庫,但是由於maven的依賴性,無法執行它的示例。無法執行噴霧示例| Maven依賴關係錯誤

如在文檔提供我已經定義了噴霧庫如下:

<repositories> 
     <repository> 
      <id>sprayrepo</id> 
      <name>spray repo</name> 
      <url>http://repo.spray.io/</url> 
      <layout>default</layout> 
     </repository> 
</repositories> 

然後如下我定義的依賴:

<dependency> 
      <groupId>io.spray</groupId> 
      <artifactId>spray-http</artifactId> 
      <version>1.1-M7</version> 
     </dependency> 
     <dependency> 
      <groupId>io.spray</groupId> 
      <artifactId>spray-httpx</artifactId> 
      <version>1.1-M7</version> 
     </dependency> 
     <dependency> 
      <groupId>io.spray</groupId> 
      <artifactId>spray-util</artifactId> 
      <version>1.1-M7</version> 
     </dependency> 
     <dependency> 
      <groupId>com.chuusai</groupId> 
      <artifactId>shapeless_2.9.2</artifactId> 
      <version>1.2.0</version> 
     </dependency> 
    </dependencies> 

然而,當我嘗試執行到Maven安裝,我面對以下錯誤:

[ERROR] Failed to execute goal on project spray-test1: Could not resolve dependencies for project org.spray:spray-test1:jar:1.0-SNAPSHOT: Failed to collect dependencies for [io.spray:spray-http:jar:1.1-M7 (compile), io.spray:spray-httpx:jar:1.1-M7 (compile), io.spray:spray-util:jar:1.1-M7 (compile), com.chuusai:shapeless_2.9.2:jar:1.2.0 (compile)]: Failed to read artifact descriptor for io.spray:spray-http:jar:1.1-M7: Could not transfer artifact io.spray:spray-http:pom:1.1-M7 from/to sprayrepo (http://repo.spray.io/): connection timed out to http://repo.spray.io/io/spray/spray-http/1.1-M7/spray-http-1.1-M7.pom -> [Help 1] [ERROR]

任何指針或建議將高度讚賞ated。

感謝

+0

這裏沒有問題,下載http://repo.spray.io/io/spray/spray-http/1.1-M7/spray-http-1.1- M7.pom – 2013-03-18 08:46:58

+0

@BGR感謝您的輸入,但我可以從我的瀏覽器瀏覽存儲庫沒有任何問題,只有當我執行mvn install命令時纔會出現此問題。 – 2013-03-18 11:46:18

+0

您的瀏覽器是通過HTTP代理服務器進行的嗎? – 2013-03-18 13:47:52

回答

2

試試這個:

<properties> 
    <maven.compiler.source>1.6</maven.compiler.source> 
    <maven.compiler.target>1.6</maven.compiler.target> 
    <encoding>UTF-8</encoding> 
    <scala.tools.version>2.10</scala.tools.version> 
    <scala.version>2.10.2</scala.version> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>org.scala-lang</groupId> 
     <artifactId>scala-library</artifactId> 
     <version>${scala.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>io.spray</groupId> 
     <artifactId>spray-can</artifactId> 
     <version>1.1-M8</version> 
    </dependency> 
    <!-- Test --> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.11</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.specs2</groupId> 
     <artifactId>specs2_${scala.tools.version}</artifactId> 
     <version>1.13</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.scalatest</groupId> 
     <artifactId>scalatest_${scala.tools.version}</artifactId> 
     <version>2.0.M6-SNAP8</version> 
     <scope>test</scope> 
    </dependency> 
    </dependencies> 
    <build> 
     <sourceDirectory>src/main/scala</sourceDirectory> 
     <testSourceDirectory>src/test/scala</testSourceDirectory> 
     <plugins> 
     <plugin> 
      <!-- see http://davidb.github.com/scala-maven-plugin --> 
      <groupId>net.alchim31.maven</groupId> 
      <artifactId>scala-maven-plugin</artifactId> 
      <version>3.1.3</version> 
      <executions> 
      <execution> 
      <goals> 
       <goal>compile</goal> 
       <goal>testCompile</goal> 
      </goals> 
      <configuration> 
      <args> 
       <arg>-make:transitive</arg> 
       <arg>-dependencyfile</arg> 
           <arg>${project.build.directory}/.scala_dependencies</arg> 
          </args> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.13</version> 
       <configuration> 
        <useFile>false</useFile> 
        <disableXmlReport>true</disableXmlReport> 
        <!-- If you have classpath issue like NoDefClassError,... --> 
        <!-- useManifestOnlyJar>false</useManifestOnlyJar --> 
        <includes> 
         <include>**/*Test.*</include> 
         <include>**/*Suite.*</include> 
        </includes> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <repositories> 
     <repository> 
      <id>SonatypeNexusSnapshots</id> 
      <name>Sonatype Nexus Snapshots</name> 
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url> 
     </repository> 
     <repository> 
      <id>FuseSourceSnapshotRepository</id> 
      <name>FuseSource Snapshot Repository</name> 
      <url>http://repo.fusesource.com/nexus/content/repositories/snapshots/</url> 
     </repository> 
     <repository> 
      <id>ScalaToolsMaven2Repository</id> 
      <name>Scala-Tools Maven2 Repository</name> 
      <url>http://scala-tools.org/repo-releases/</url> 
     </repository> 
     <repository> 
      <id>scala-tools.org</id> 
      <name>Scala-Tools Maven2 Repository</name> 
      <url>http://scala-tools.org/repo-releases</url> 
     </repository> 
     <repository> 
      <id>sprayrepo</id> 
      <name>spray repo</name> 
      <url>http://repo.spray.io/</url> 
      <layout>default</layout> 
     </repository> 
    </repositories> 

    <pluginRepositories> 
     <pluginRepository> 
      <id>scala-tools.org</id> 
      <name>Scala-Tools Maven2 Repository</name> 
      <url>http://scala-tools.org/repo-releases</url> 
     </pluginRepository> 
    </pluginRepositories> 
+0

oof!看到這個後我更喜歡SBT! :) – AmigoNico 2014-12-28 05:54:40