I'm trying to import WKBReader by including import org.geotools.data.postgis.WKBReader;
.
The WKBReader class should be in org.geotools.data.postgis
according to the documentation, but package is not available for me.
I tried to add the gt-postgis repository to pom.xml
as:
<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>
...
...but with no luck. I always get errors like:
Failed to execute goal on project tutorial: Could not resolve dependencies for project org.geotools:tutorial:jar:1.0-SNAPSHOT: Failure to find org.geotools:gt-postgis:jar:17.1 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]
My question: where is org.geotools:gt-postgis:jar:17.1
?
My complete 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
A quick check of the documentation shows you need the following in your pom:
<dependency>
<groupId>org.geotools.jdbc</groupId>
<artifactId>gt-jdbc-postgis</artifactId>
<version>${geotools.version}</version>
</dependency>