为什么我无法解决GeoTools maven quickstart的依赖关系?

时间:2013-04-25 22:07:37

标签: maven geotools

POM

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.geotools</groupId>
    <artifactId>tutorial</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>tutorial</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <geotools.version>10-SNAPSHOT</geotools.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-shapefile</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-swing</artifactId>
            <version>${geotools.version}</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Java.net repository</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>osgeo</id>
            <name>Open Source Geospatial Foundation Repository</name>
            <url>http://download.osgeo.org/webdav/geotools/</url>
        </repository>
    </repositories>
</project>

我收到错误:

[ERROR] Failed to execute goal on project tutorial: Could not resolve dependencies for project org.geotools:tutorial:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: org.geotools:gt-shapefile:jar:10-SNAPSHOT, org.geotools:gt-swing:jar:10-SNAPSHOT: Could not find artifact org.geotools:gt-shapefile:jar:10-SNAPSHOT in maven2- repository.dev.java.net (http://download.java.net/maven/2) -> [Help 1]

为什么不能解决这些工件。 GeoTools有其他指令(我无法工作),但我想知道这是错误的。

由于

5 个答案:

答案 0 :(得分:15)

出现此问题是因为org.geotools:gt-shapefile:jar:10-SNAPSHOThttp://download.java.net/maven/2http://download.osgeo.org/webdav/geotools不存在。您所要做的就是为snapshot repository定义GeoTools,如the GeoTools:Maven Quick Start中提到的那样: -

<repositories>
    <repository>
        <id>maven2-repository.dev.java.net</id>
        <name>Java.net repository</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>osgeo</id>
        <name>Open Source Geospatial Foundation Repository</name>
        <url>http://download.osgeo.org/webdav/geotools/</url>
    </repository>
    <repository> <!--Add the snapshot repository here-->
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>opengeo</id>
        <name>OpenGeo Maven Repository</name>
        <url>http://repo.opengeo.org</url>
    </repository>
</repositories>

我希望这可能有所帮助。

答案 1 :(得分:14)

以上答案中的某些存储库已移至其他地址。添加以下存储库为我解决了这个问题。

 <repository>
      <id>osgeo-alt</id>
      <url>https://repo.osgeo.org/repository/release/</url>
 </repository>
 <repository>
       <id>geomajas</id>
       <name>Geomajas Maven Repository</name>
       <url>http://maven.geomajas.org/(http://maven.geomajas.org/)</url>
 </repository>

答案 2 :(得分:1)

您应该添加Boundless存储库并编写 http https indtead:

<repositories>
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Java.net repository</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>osgeo</id>
            <name>Open Source Geospatial Foundation Repository</name>
            <url>https://download.osgeo.org/webdav/geotools/</url>
        </repository>
        <repository>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <id>boundless</id>
            <name>Boundless Maven Repository</name>
            <url>https://repo.boundlessgeo.com/main/</url>
        </repository>
    </repositories>

它将使一切正常。

答案 3 :(得分:0)

http://download.java.net/maven/2 存储库已消失

新更新,在项目中添加geotools依赖项的新方法,复制到build.xml中的xml文件

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <geotools.version>19-SNAPSHOT</geotools.version>
    </properties>

<dependencies>

        <dependency>
            <groupId>com.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>3.3</version>
        </dependency>


        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-shapefile</artifactId>
            <version>${geotools.version}</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-swing</artifactId>
            <version>${geotools.version}</version>
        </dependency>

    </dependencies>

<repositories>

        <repository>
            <id>osgeo</id>
            <name>Open Source Geospatial Foundation Repository</name>
            <url>http://download.osgeo.org/webdav/geotools/</url>
        </repository>
        <repository>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <id>boundless</id>
            <name>Boundless Maven Repository</name>
            <url>http://repo.boundlessgeo.com/main</url>
        </repository>
    </repositories>

它有效

答案 4 :(得分:0)

当前可用的osgeo存储库:

<repository>      
  <id>geotools</id>
  <name>Geotools repository</name>
  <!--<url>http://download.osgeo.org/webdav/geotools/</url>-->
  <url>https://repo.osgeo.org/repository/geotools-releases/</url>
</repository>