首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven缺少工件org.Geotools:gt-shapefile:jar:11-快照

Maven缺少工件org.Geotools:gt-shapefile:jar:11-快照
EN

Stack Overflow用户
提问于 2013-09-29 10:05:18
回答 6查看 14.9K关注 0票数 5

你好,我正在尝试用maven编写一个简单的geotools项目。事实上,我对maven非常陌生。我打开了新的maven项目,设置了设置并编写了一些代码。如我所知,maven应该下载并安装需要的geotools jar文件。但是A正在得到“丢失工件org.Geotools:gt-shapefile:jar:11-快照”错误,我不明白为什么会这样。

我的工作环境:

日食开普勒,Jdk 6,Maven-最新版本,Geotools-最新版本

这是我的pom.xml

代码语言:javascript
复制
<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>11-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>

这是我的Quickstart课程

代码语言:javascript
复制
    package org.geotools.tutorial;

import java.io.File;

import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.map.FeatureLayer;
import org.geotools.map.Layer;
import org.geotools.map.MapContent;
import org.geotools.styling.SLD;
import org.geotools.styling.Style;
import org.geotools.swing.JMapFrame;
import org.geotools.swing.data.JFileDataStoreChooser;

/**
 * Prompts the user for a shapefile and displays the contents on the screen in a map frame.
 * <p>
 * This is the GeoTools Quickstart application used in documentationa and tutorials. *
 */
public class Quickstart {

    /**
     * GeoTools Quickstart demo application. Prompts the user for a shapefile and displays its
     * contents on the screen in a map frame
     */
    public static void main(String[] args) throws Exception {
        // display a data store file chooser dialog for shapefiles
        File file = JFileDataStoreChooser.showOpenFile("shp", null);
        if (file == null) {
            return;
        }

        FileDataStore store = FileDataStoreFinder.getDataStore(file);
        SimpleFeatureSource featureSource = store.getFeatureSource();

        // Create a map content and add our shapefile to it
        MapContent map = new MapContent();
        map.setTitle("Quickstart");

        Style style = SLD.createSimpleStyle(featureSource.getSchema());
        Layer layer = new FeatureLayer(featureSource, style);
        map.addLayer(layer);

        // Now display the map
        JMapFrame.showMap(map);
    }

}

我只是写了我没有下载或安装任何罐子的代码。我以maven项目的形式打开了这个项目。我想知道maven何时以及如何下载和安装jars?

谢谢。

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2013-09-29 10:38:02

尝试用:http://repo.opengeo.org/替换存储库URL

票数 3
EN

Stack Overflow用户

发布于 2020-05-08 12:52:27

我知道这是很古老的,但在寻找问题时仍然是第一位的。URL再次更改,现在是:

代码语言:javascript
复制
<repository>
    <id>osgeo</id>
    <name>OSGeo Release Repository</name>
    <url>https://repo.osgeo.org/repository/release/</url>
  </repository>

或者如果您想启用快照:

代码语言:javascript
复制
  <repository>
    <id>osgeo</id>
    <name>OSGeo Release Repository</name>
    <url>https://repo.osgeo.org/repository/release/</url>
    <snapshots><enabled>false</enabled></snapshots>
    <releases><enabled>true</enabled></releases>
  </repository>
  <repository>
    <id>osgeo-snapshot</id>
    <name>OSGeo Snapshot Repository</name>
    <url>https://repo.osgeo.org/repository/snapshot/</url>
    <snapshots><enabled>true</enabled></snapshots>
    <releases><enabled>false</enabled></releases>
  </repository>

也见项目网站指南

票数 11
EN

Stack Overflow用户

发布于 2013-09-29 10:21:18

Maven在其生命周期的一个阶段下载并将jars放到本地存储库中,我不确定是哪个阶段,但是如果您运行mvn clean install,它应该下载项目所需的所有jars。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19076733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档