1

我是第一次使用 Maven。我正在尝试构建“GeoTools”(http://www.geotools.org/),它有一个看似有据可查的“入门”页面。我正在使用 NetBeans 7.3.1。当我构建我的项目时,我得到一个“构建失败”:

Failed to execute goal on project tutorial: Could not resolve dependencies for project org.geotools:tutorial:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.geotools:gt-shapefile:jar:10-SNAPSHOT, org.geotools:gt-swing:jar:10-SNAPSHOT: Failure to find org.geotools:gt-shapefile:jar:10-SNAPSHOT in http://download.java.net/maven/2 was cached in the local repository, resolution will not be reattempted until the update interval of maven2-repository.dev.java.net has elapsed or updates are forced -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

我不太确定那是什么意思。在我的代码中,我有几个被认为不存在的导入,尽管我完全按照 pom.xml 说明进行操作。例如:

import org.geotools.data.FileDataStore;

上面有一条阅读下划线,错误提示:

package org.geotools.data does not exist

这是我的 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.geotools</groupId>
<artifactId>tutorial</artifactId>
<version>0.0.1-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>

谁能给我一些建议来运行这个工具?我是在犯一个基本的 Maven 错误还是可能是特定于工具的?JAR 显示在“依赖项”下,所以我不明白为什么会出现问题。

提前致谢。

4

1 回答 1

2

真正的答案是 GeoTools 教程是有害的。因此,如果任何未来的落后者来到这里都知道这一点:在 NetBeans 教程(也许还有我也未能开始工作的 Eclipse 教程)中,有一些步骤定义了如何设置 pom.xml。跟着他们。但是,不要复制并粘贴他们的完整 pom.xml 文件,它的某处有错误。我只是添加了依赖项和存储库并成功构建了项目。

但是等等还有更多。构建项目后,我无法运行他们提供的 Quickstart.java 示例。它崩溃了,因为

JMapFrame.showMap(map)

只接受“MapContext”类型,文档称之为“已弃用”。所以,我进口了

org.geotools.map.MapContext

并改变了

MapContent map = new MapContent();

MapContext map = new MapContext();

维奥拉,打败了系统。我希望开发人员能够真正测试他们的教程!

于 2013-07-09T21:20:49.163 回答