2013-07-09 99 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

相關問題