我是第一次使用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显示在"依赖项"下,所以我不明白为什么会出现问题。
提前谢谢。
但等等,还有更多。在构建项目后,我无法运行他们提供的Quickstart.java示例。它崩溃是因为
JMapFrame.showMap(map)
只接受"MapContext"类型,文档称之为"弃用"。所以,我进口了
org.geotools.map.MapContext
并更改
MapContent map = new MapContent();
至
MapContext map = new MapContext();
维奥拉,打败了体制。我希望开发人员能够真正测试他们的教程!