GeoServer開發環境搭建

拂衣志發表於2024-05-04

前言

本文用於記錄GeoServer開發環境的搭建過程

release

透過GeoServer釋出計劃可以看到,在2.23.x版本開始,會移除對jdk1.8的支援。那麼當前我們會選擇2.22.x版本進行研究

環境

  • JAVA:1.8或11
  • Maven
  • Git

Action

獲取原始碼


git clone git://github.com/geoserver/geoserver.git geoserver

# or

git clone https://github.com/geoserver/geoserver.git geoserver

程式碼庫結構

Each branch has the following structure:

  • build - release and continuous integration scripts
  • doc - sources for the user and developer guides
  • src - java sources for GeoServer itself
  • data - a variety of GeoServer data directories / configurations

切換到2.22.x分支


# 檢視分支
git branch -av

# 切換分支
git checkout -b 2.22.x origin/2.22.x

002-002

002-003

Import modules into IntelliJ

  1. Run the IntelliJ IDE

  2. From the initial panel select Open.

002-004

  1. Navigate to the geoserver/src/pom.xml directory and click OK.

002-005

  1. When asked click on Open as a Project.

002-006

  1. Optionally, depending on which platform, IntelliJ may ask to Trust the Project.

002-007

  1. Wait for IntelliJ to Sync the dependencies, it’s possible to follow the process from the Build tab panel on the bottom.

002-008

Finalize the GeoServer Project configuration

  1. Click File > Project Structure.

002-009

  1. Update the Name and select the correct SDK accordingly to the GeoServer version.

002-010

  1. Click File > Settings.

002-011

  1. From Build, Execution, Deployment > Compiler > Annotation Processors, enable the Annotation processing.

002-012

  1. Click Build > Rebuild Project.

002-013

Run GeoServer from IntelliJ

  1. From the Project browser select the web-app module
  2. Navigate to the org.geoserver.web package
  3. Right-click the Start class and click to Modify Run Configuration...

如果沒有該選項,那麼直接去Edit Configurations處建立一個即可,Add Configuration,選擇Application

002-014

  1. It is important to correctly set the Working directory to src/web/app. While having the Edit Configurations dialog open, fine tune the launch environment (including setting a GEOSERVER_DATA_DIR or the jetty.port). When settings are satisfactory, click OK.

002-015

002-016

  1. It’s possible now to run GeoServer by selecting Run -> Run 'Start'

002-017

第一次啟動比較慢

002-018

Access GeoServer front page

  • After a few seconds, GeoServer should be accessible at: http://localhost:8080/geoserver
  • The default admin password is geoserver.

FAQ

依賴下載失敗或過慢(該條僅供參考)

使用阿里雲Maven映象加速依賴下載,可以參考阿里雲Maven嚮導進行設定【有代理應該就不需要了】

maven配置檔案優先順序,maven工具所在的conf配置 > 外部化配置

編譯提示Node不存在(wcs1_1)

002-019

網路上有一些提示是:手動新增Node的依賴。但是我認為應該不需要手動設定才是,因為從官網的maven quick start中,並未使用任何的編輯器,直接命令列搞定。


# skip unit tests, skip spotless(Spotless is used as a fast way to check that the google-java-format is being applied to the codebase.)

mvn clean install -DskipTests -Dspotless.apply.skip=true

# 不想install, package也可以

mvn clean package -DskipTests -Dspotless.apply.skip=true

這個時候可以看到,Node這個類存在於編譯後的程式碼中

002-020

透過跟蹤構建過程可以看到,是由javacc在編譯過程中生成的(根據rangeset.jjt檔案,知識盲區了)

002-021

其實在官方文件中已經提到了如何處理該問題的,參見Troubleshooting#1,就是需要先完成wcs1_1模組的編譯構建。

我就不管那麼多了,直接把所有的都構建了

Maven 使用

參見:GeoServer Maven Guide

參考

  • IntelliJ QuickStart

  • GeoServer Maven Guide

  • 阿里云云效Maven

相關文章