我试图通过加入import org.geotools.data.postgis.WKBReader;
来导入WKBReader。
WKBReader类应位于org.geotools.data.postgis
according to the documentation,但我无法使用该包。
我尝试将gt-postgis存储库添加到pom.xml
:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<geotools.version>17.1</geotools.version>
</properties>
...
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-postgis</artifactId>
<version>${geotools.version}</version>
</dependency>
...
......但没有运气。我总是得到错误:
无法在项目教程上执行目标:无法解析项目org.geotools的依赖项:tutorial:jar:1.0-SNAPSHOT:找不到org.geotools:gt {postgis:jar:17.1在http://download.java.net/maven/2中缓存在本地存储库中,在经过maven2-repository.dev.java.net的更新间隔或强制更新之前,不会重新尝试解析 - &gt; [帮助1]
我的问题:org.geotools:gt-postgis:jar:17.1
在哪里?
我的完整pom.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>1.0-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>17.1</geotools.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</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-geojson</artifactId>
<version>${geotools.version}</version>
</dependency-->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-postgis</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>
<repository> <!--Add the snapshot repository here-->
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>opengeo</id>
<name>OpenGeo Maven Repository</name>
<url>http://repo.opengeo.org</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.geotools.tutorial.quickstart.GeoJson2Shape</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
mvn log:
BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.530 s
[INFO] Finished at: 2017-08-04T12:22:50+02:00
[INFO] Final Memory: 20M/299M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project tutorial: Compilation failure: Compilation failure:
[ERROR] /data/osm/maven/geotools/tutorial/src/main/java/org/geotools/tutorial/quickstart/WKB2Shape.java:[30,33] package org.geotools.data.postgis does not exist
[ERROR] /data/osm/maven/geotools/tutorial/src/main/java/org/geotools/tutorial/quickstart/WKB2Shape.java:[56,9] cannot find symbol
[ERROR] symbol: class WKBReader
[ERROR] location: class org.geotools.tutorial.quickstart.WKB2Shape
[ERROR] /data/osm/maven/geotools/tutorial/src/main/java/org/geotools/tutorial/quickstart/WKB2Shape.java:[56,35] cannot find symbol
[ERROR] symbol: class WKBReader
[ERROR] location: class org.geotools.tutorial.quickstart.WKB2Shape
[ERROR] /data/osm/maven/geotools/tutorial/src/main/java/org/geotools/tutorial/quickstart/WKB2Shape.java:[58,9] cannot find symbol
[ERROR] symbol: class Geometry
[ERROR] location: class org.geotools.tutorial.quickstart.WKB2Shape
答案 0 :(得分:0)
您要连接哪个存储库?你可以分享那些maven的细节。
像这样的事情<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
答案 1 :(得分:0)
快速检查documentation表示您需要在pom中使用以下内容:
from django.db import models
class Customer(models.Model):
name = models.CharField(max_length=30)
latitude = models.FloatField(default=0)
longitude = models.FloatField(default=0)
class Product(models.Model):
name = models.CharField(max_length=30)
weight = models.FloatField(default=0)
class Order(models.Model):
customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
timestamp = models.DateTimeField(auto_now=True)
line_items = models.ManyToManyField(Product, through='OrderItem')
class OrderItem(models.Model):
product = models.ForeignKey(Product)
order = models.ForeignKey(Order)
quantity, price, discount, ...