geotools相关maven 引入

<?xml version="1.0" encoding="UTF-8"?>

<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>tutorial1</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>tutorial1</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <geotools.version>29-SNAPSHOT</geotools.version>
    <maven.deploy.skip>true</maven.deploy.skip>
  </properties>

  <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>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</id>
      <name>Open Source Geospatial Foundation Repository</name>
      <url>http://download.osgeo.org/webdav/geotools/</url>
    </repository>
    <repository>
      <id>osgeo-snapshot</id>
      <name>OSGeo Release Repository</name>
      <url> https://repo.osgeo.org/repository/snapshot/</url>
      <snapshots><enabled>true</enabled></snapshots>
      <releases><enabled>false</enabled></releases>
    </repository>

    <repository>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>boundless</id>
      <name>Boundless Maven Repository</name>
      <url>http://repo.boundlessgeo.com/main</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</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>
    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt-geotiff</artifactId>
      <version>${geotools.version}</version>
    </dependency>
    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt-geojson</artifactId>
      <version>${geotools.version}</version>
    </dependency>

    <dependency>
      <groupId>org.geotools.jdbc</groupId>
      <artifactId>gt-jdbc-postgis</artifactId>
      <version>${geotools.version}</version>
    </dependency>

    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt-cql</artifactId>
      <version>${geotools.version}</version>
    </dependency>



    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt-epsg-hsql</artifactId>
      <version>${geotools.version}</version>
    </dependency>

<!--    <dependency>-->
<!--      <groupId>org.wololo</groupId>-->
<!--      <artifactId>jts2geojson</artifactId>-->
<!--      <version>0.17.0</version>-->
<!--    </dependency>-->

  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>

        <plugin>
          <inherited>true</inherited>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.10.1</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>8</source>
          <target>8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
创建项目命令
mvn archetype:generate -DgroupId=org.geotools -DartifactId=tutorial -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart

<think>嗯,用户想配置GeoToolsMaven的集成,或者依赖配置。首先,我需要回忆一下GeoToolsMaven仓库配置。记得GeoTools的依赖不在Maven中央仓库,所以需要添加它们的仓库地址。比如,用户需要在pom.xml中添加GeoTools的仓库,比如https://repo.osgeo.org/repository/release/。另外,可能需要配置repository和pluginRepository。 然后,具体的依赖配置。GeoTools有很多模块,用户可能需要根据需求引入不同的模块,比如gt-main、gt-shapefile等。每个模块都有对应的groupId和artifactId,通常是org.geotools,然后是模块名。版本的话,用户需要指定正确的版本号,比如最新的31.0或者根据项目需要选合适的版本。 另外,可能还需要考虑OSGeo的仓库认证问题,有些仓库可能需要认证,但公开的仓库应该可以直接使用。用户可能遇到依赖无法下载的问题,这时候需要检查仓库配置是否正确,版本号是否存在。 还有,可能用户在使用过程中会遇到类冲突或者依赖管理的问题,建议使用Bill of Materials(BOM)来统一管理版本,比如引入geotools-bom,这样可以避免版本不一致的问题。 另外,示例的pom.xml配置可能会有帮助,用户可以参考如何正确添加仓库和依赖。还要注意Maven的settings.xml是否需要配置镜像或者代理,但大部分情况下,添加仓库到pom.xml就足够了。 最后,可能需要提醒用户根据实际需求选择模块,比如处理Shapefile需要gt-shapefile,空间分析需要gt-process等。同时,GeoTools的文档和官网资源也是重要的参考,确保用户能获取最新的信息和示例。</think>### GeoToolsMaven集成配置步骤 1. **添加OSGeo仓库配置** GeoTools的依赖托管在OSGeo仓库中,需在`pom.xml`中添加以下配置: ```xml <repositories> <repository> <id>osgeo</id> <name>OSGeo Release Repository</name> <url>https://repo.osgeo.org/repository/release/</url> </repository> </repositories> ``` 2. **配置GeoTools依赖** 根据需求选择模块,例如基础功能模块`gt-main`和Shapefile支持模块`gt-shapefile`: ```xml <dependencies> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-main</artifactId> <version>31.0</version> <!-- 替换为最新版本 --> </dependency> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-shapefile</artifactId> <version>31.0</version> </dependency> </dependencies> ``` 3. **版本统一管理(可选)** 使用BOM(Bill of Materials)避免版本冲突: ```xml <dependencyManagement> <dependencies> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-bom</artifactId> <version>31.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> ``` 4. **完整示例`pom.xml`** ```xml <project> <!-- ...其他配置 --> <repositories> <repository> <id>osgeo</id> <url>https://repo.osgeo.org/repository/release/</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-main</artifactId> <version>31.0</version> </dependency> </dependencies> </project> ``` ### 关键注意事项 - **模块选择**:GeoTools包含$20+$模块,例如`gt-geojson`(GeoJSON支持)、`gt-process`(空间分析)等,需按需引入[^1]。 - **版本兼容性**:确保所有GeoTools模块使用相同版本号。 - **代理问题**:若仓库访问失败,可尝试在Maven的`settings.xml`中配置镜像。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值