2013-07-09 66 views
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出现在“Dependencies”下,所以我不明白为什么会有问题。

在此先感谢。

回答

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(); 

中提琴,打浆加制。我希望开发人员能够真正测试他们的教程!

+1

你做得很好:) – MaVRoSCy

相关问题