2

我只是想动手使用 Spray 库,但是由于 maven 依赖性而无法执行它的示例。

正如文档中所提供的,我已将 Spray 存储库定义如下:

<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 安装时,我遇到以下错误:

[错误] 无法在项目 spray-test1 上执行目标:无法解析项目 org.spray:spray-test1:jar:1.0-SNAPSHOT 的依赖项:无法收集 [io.spray:spray-http:jar:1.1 的依赖项-M7 (编译), io.spray:spray-httpx:jar:1.1-M7 (编译), io.spray:spray-util:jar:1.1-M7 (编译), com.chuusai:shapeless_2.9.2:jar: 1.2.0(编译)]:无法读取 io.spray:spray-http:jar:1.1-M7 的工件描述符:无法将工件 io.spray:spray-http:pom:1.1-M7 从/到 sprayrepo 传输(http://repo.spray.io/):连接超时 http://repo.spray.io/io/spray/spray-http/1.1-M7/spray-http-1.1-M7.pom -> [帮助 1] [错误]

任何指针或建议将不胜感激。

谢谢

4

1 回答 1

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>
于 2013-08-19T16:12:25.207 回答