一、用到geotools 打包部署问题
问题:geotools包依赖不能用本地离线包,打包报错问题
解决方法:
1.先配置在线下载geotools,在pom.xml
<properties>
<java.version>1.8</java.version>
<geotools.version>25.2</geotools.version>
</properties>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-metadata</artifactId>
<version>${geotools.version}</version>
</dependency>
<repositories>
<!--在线geotools的远程库-->
<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>
<!--GeoServer-->
<repository>
<id>GeoSolutions</id>
<url>http://maven.geo-solutions.it/</url>
</repository>
</repositories>
2.配置好,就到maven projects- Lifecycle -install ;就是先打包一下,让其能在线下载geotools到本地的maven 里面
3.如果下载不了的话,就得到 https://sourceforge.net/projects/geotools/ 下载相关的对应的版本,然后到本地的maven
D:\hjysetting\apache-maven-3.6.1\repository\org\geotools 一一对应加进去
4.注意有些geotools版本是需要其他依赖的比如25.2版本的geotools,需要下面的依赖的
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>si.uom</groupId>
<artifactId>si-quantity</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>si.uom</groupId>
<artifactId>si-units</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>tech.uom.lib</groupId>
<artifactId>uom-lib-common</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>systems.uom</groupId>
<artifactId>systems-common</artifactId>
<version>2.0.2</version>
</dependency>
-----------
参考:
pom.xml
<properties>
<java.version>1.8</java.version>
<geotools.version>25.2</geotools.version>
<!--<geotools.lib.dir>${project.basedir}/src/main/resources/lib/geotools-25.2</geotools.lib.dir>-->
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--hjy-->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-metadata</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-opengis</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>si.uom</groupId>
<artifactId>si-quantity</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>si.uom</groupId>
<artifactId>si-units</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>tech.uom.lib</groupId>
<artifactId>uom-lib-common</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>systems.uom</groupId>
<artifactId>systems-common</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version> <!-- Or the latest version -->
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.18.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<!--在线geotools的远程库-->
<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>
<!--GeoServer-->
<repository>
<id>GeoSolutions</id>
<url>http://maven.geo-solutions.it/</url>
</repository>
</repositories>