eclipse中建geoserver源码

概述:本文讲述的是在eclipse中如何构建geoserver源码工程,其中涉及到了jdk,github,marven等。 

1、安装git

 从(http://git-scm.com/download/win),获得Git-1.9.0-preview2014021 7.exe文件,直接安装即可。安装成功后,在任何处所右击鼠标,出现如下图所示:

百度网盘下载

2、从git中签出geoserver源码

点击“Git GUI”将呈现如下界面,选择“克隆已有版本”,进入源码克隆界面,输入响应的source Location(源码地点地位git://github.com/geoserver/geoserver.git) 和 Target Location(本地存储地位)。

克隆已有版本

输入参数

克隆完成后,源代码的组织如下:

3、下载并配置Maven

 (http://maven.apache.org/download.cgi)选择apache-maven-3.21-bin.zip,maven是号令行法度,将获得的紧缩包解压,解压后文件组织如下:

并添加D:softwarejavawebmavenin到path变量中。

maven百度网盘下载地址

4、通过maven构建源码

4.1  跳转路径到geoserver的src目录下

[plain] view plain copy
 
  1. C:UsersAdministrator>d:  
  2. D:>cd D:opengisopengissrc  
  3. D:opengisopengissrc>  
4.2 临时将maven的路径添加至环境变量中

执行如下命令:

[plain] view plain copy
 
  1. Set PATH = “maven_dir/bin”;%PATH%  
4.3 构建工程

执行如下命令,构建工程:

[plain] view plain copy
 
  1. mvn clean install  
  2. mvn -DskipTests clean install  

注意:第一条号令在构建的同时履行测试用例测试类文件,在号令履行过程中有可能会呈现错误;第二条号令在构建时,不进行测试,不会有测试不经由过程的异常。

执行命令输出:

[plain] view plain copy
 
  1. [INFO] ------------------------------------------------------------------------  
  2. [INFO] Reactor Summary:  
  3. [INFO]  
  4. [INFO] GeoServer ......................................... SUCCESS [  5.916 s]  
  5. [INFO] Core Platform Module .............................. SUCCESS [  5.763 s]  
  6. [INFO] Open Web Service Module ........................... SUCCESS [  6.644 s]  
  7. [INFO] Main Module ....................................... SUCCESS [01:15 min]  
  8. [INFO] GeoServer Security Modules ........................ SUCCESS [  0.607 s]  
  9. [INFO] GeoServer JDBC Security Module .................... SUCCESS [  8.048 s]  
  10. [INFO] GeoServer LDAP Security Module .................... SUCCESS [  8.002 s]  
  11. [INFO] Web Coverage Service Module ....................... SUCCESS [  3.605 s]  
  12. [INFO] Web Coverage Service 1.0 Module ................... SUCCESS [  6.524 s]  
  13. [INFO] Web Coverage Service 1.1 Module ................... SUCCESS [ 10.715 s]  
  14. [INFO] Web Coverage Service 2.0 Module ................... SUCCESS [ 13.674 s]  
  15. [INFO] Web Feature Service Module ........................ SUCCESS [ 18.692 s]  
  16. [INFO] Web Map Service Module ............................ SUCCESS [03:41 min]  
  17. [INFO] KML support for GeoServer ......................... SUCCESS [01:17 min]  
  18. [INFO] GeoWebCache (GWC) Module .......................... SUCCESS [03:34 min]  
  19. [INFO] REST Support Module ............................... SUCCESS [  3.981 s]  
  20. [INFO] REST Configuration Service Module ................. SUCCESS [01:23 min]  
  21. [INFO] GeoServer Web Modules ............................. SUCCESS [  0.162 s]  
  22. [INFO] Core UI Module .................................... SUCCESS [02:46 min]  
  23. [INFO] WMS UI Module ..................................... SUCCESS [  5.256 s]  
  24. [INFO] GWC UI Module ..................................... SUCCESS [ 10.776 s]  
  25. [INFO] WFS UI Module ..................................... SUCCESS [  3.262 s]  
  26. [INFO] Demoes Module ..................................... SUCCESS [01:08 min]  
  27. [INFO] WCS UI Module ..................................... SUCCESS [  4.632 s]  
  28. [INFO] Security UI Modules ............................... SUCCESS [  0.155 s]  
  29. [INFO] Security UI Core Module ........................... SUCCESS [  7.840 s]  
  30. [INFO] Security UI JDBC Module ........................... SUCCESS [  4.315 s]  
  31. [INFO] Security UI LDAP Module ........................... SUCCESS [ 12.600 s]  
  32. [INFO] GeoServer Web Application ......................... SUCCESS [01:42 min]  
  33. [INFO] Community Space ................................... SUCCESS [  7.778 s]  
  34. [INFO] GeoServer Extensions .............................. SUCCESS [  0.226 s]  
  35. [INFO] ------------------------------------------------------------------------  
  36. [INFO] BUILD SUCCESS  
  37. [INFO] ------------------------------------------------------------------------  
  38. [INFO] Total time: 19:21 min  
  39. [INFO] Finished at: 2014-03-05T16:52:55+08:00  
  40. [INFO] Final Memory: 188M/368M  
  41. [INFO] ------------------------------------------------------------------------  
4.4 通过maven创建eclipse工程文件

执行命令:

[plain] view plain copy
 
  1. mvn eclipse:eclipse  
执行结果如下:
[plain] view plain copy
 
  1. [INFO] ------------------------------------------------------------------------  
  2. [INFO] Reactor Summary:  
  3. [INFO]  
  4. [INFO] GeoServer ......................................... SUCCESS [ 10.022 s]  
  5. [INFO] Core Platform Module .............................. SUCCESS [  6.761 s]  
  6. [INFO] Open Web Service Module ........................... SUCCESS [  4.690 s]  
  7. [INFO] Main Module ....................................... SUCCESS [  8.291 s]  
  8. [INFO] GeoServer Security Modules ........................ SUCCESS [  0.041 s]  
  9. [INFO] GeoServer JDBC Security Module .................... SUCCESS [  0.759 s]  
  10. [INFO] GeoServer LDAP Security Module .................... SUCCESS [  1.313 s]  
  11. [INFO] Web Coverage Service Module ....................... SUCCESS [  0.299 s]  
  12. [INFO] Web Coverage Service 1.0 Module ................... SUCCESS [  1.545 s]  
  13. [INFO] Web Coverage Service 1.1 Module ................... SUCCESS [  4.898 s]  
  14. [INFO] Web Coverage Service 2.0 Module ................... SUCCESS [  0.354 s]  
  15. [INFO] Web Feature Service Module ........................ SUCCESS [  0.502 s]  
  16. [INFO] Web Map Service Module ............................ SUCCESS [  3.534 s]  
  17. [INFO] KML support for GeoServer ......................... SUCCESS [  1.063 s]  
  18. [INFO] GeoWebCache (GWC) Module .......................... SUCCESS [  9.024 s]  
  19. [INFO] REST Support Module ............................... SUCCESS [  0.285 s]  
  20. [INFO] REST Configuration Service Module ................. SUCCESS [  0.484 s]  
  21. [INFO] GeoServer Web Modules ............................. SUCCESS [  0.032 s]  
  22. [INFO] Core UI Module .................................... SUCCESS [  0.922 s]  
  23. [INFO] WMS UI Module ..................................... SUCCESS [  0.338 s]  
  24. [INFO] GWC UI Module ..................................... SUCCESS [  1.009 s]  
  25. [INFO] WFS UI Module ..................................... SUCCESS [  0.274 s]  
  26. [INFO] Demoes Module ..................................... SUCCESS [  0.408 s]  
  27. [INFO] WCS UI Module ..................................... SUCCESS [  0.604 s]  
  28. [INFO] Security UI Modules ............................... SUCCESS [  0.033 s]  
  29. [INFO] Security UI Core Module ........................... SUCCESS [  0.319 s]  
  30. [INFO] Security UI JDBC Module ........................... SUCCESS [  0.331 s]  
  31. [INFO] Security UI LDAP Module ........................... SUCCESS [  0.401 s]  
  32. [INFO] GeoServer Web Application ......................... SUCCESS [  0.595 s]  
  33. [INFO] Community Space ................................... SUCCESS [  0.032 s]  
  34. [INFO] GeoServer Extensions .............................. SUCCESS [  0.030 s]  
  35. [INFO] ------------------------------------------------------------------------  
  36. [INFO] BUILD SUCCESS  
  37. [INFO] ------------------------------------------------------------------------  
  38. [INFO] Total time: 01:09 min  
  39. [INFO] Finished at: 2014-03-05T17:06:55+08:00  
  40. [INFO] Final Memory: 119M/447M  
  41. [INFO] ------------------------------------------------------------------------  
  42. D:TechnologyLearnningopen_gisgeoservergeoserver_devprojectgeoserver20140305src>  
5、将工程导入eclipse并运行

5.1 添加Classpath Variables

打开eclipse,选择window下的preference,在对话框中选择java->buildpath->Classpath Variables,点击“new”将本地的maven     repository路径作为classpath变量添加至工作空间中。

5.2 导入工程

在eclipse中点击 “file”选择“import”将创建的eclipse导入至eclipse中。

import

存在的工程

选择geoserver/src文件夹

导入后,布局如下:

5.3 运行

运行start.java

Console中呈现如下记录:

[plain] view plain copy
 
  1. log4j:WARN File option not set for appender [geoserverlogfile].  
  2. log4j:WARN Are you using FileAppender instead of ConsoleAppender?  
  3. 三月 05, 2014 9:31:37 下午 org.geoserver.platform.GeoServerExtensions checkContext  
  4. 警告: Extension lookup occured, but ApplicationContext is unset.  
  5. 05 三月 21:31:37 INFO [geoserver.global] -  
  6. ----------------------------------  
  7. - GEOSERVER_DATA_DIR: D:TechnologyLearnningopen_gisgeoservergeoserver_devprojectgeoserver20140305srcwebappsrcmainwebappdata  
  8. ----------------------------------  
  9. 05 三月 21:31:38 INFO [org.geoserver] - Loaded style ""line""  
  10. 05 三月 21:31:38 INFO [org.geoserver] - Loaded style ""point""  
  11. 05 三月 21:31:38 INFO [org.geoserver] - Loaded style ""polygon""  
  12. 05 三月 21:31:38 INFO [org.geoserver] - Loaded style ""raster""  
  13. 05 三月 21:31:38 INFO [org.geoserver] - Loaded default workspace it.geosolutions  
  14. 05 三月 21:31:38 INFO [org.geoserver] - Loaded workspace ""it.geosolutions""  
  15. 05 三月 21:31:38 INFO [org.geoserver] - Loaded workspace ""topp""  
  16. 05 三月 21:31:38 INFO [storage.DefaultStorageFinder] - ************************************************************************************************************  
  17. 05 三月 21:31:38 INFO [storage.DefaultStorageFinder] - *** Found System environment variable TEMP set to C:UserssmartmapAppData  
  18. LocalTemp, using it as the default prefix. ***  
  19. 05 三月 21:31:38 INFO [storage.DefaultStorageFinder] - *************************************************************************************************************  
  20. 05 三月 21:31:38 INFO [config.XMLConfiguration] - Will look for geowebcache.xml in ""C:UserssmartmapAppDataLocalTempgeowebcache""  
  21. 05 三月 21:31:38 INFO [gwc.layer] - Initializing GWC configuration based on GeoServer""s Catalog  
  22. 05 三月 21:31:38 INFO [gwc.layer] - GeoServer TileLayer store base directory is: D:TechnologyLearnningopen_gisgeoservergeoserver_devprojectgeoserver20140305srcwebappsrcmainwebappdatagwc-layers  
  23. 05 三月 21:31:38 INFO [gwc.layer] - Loading tile layers D:TechnologyLearnningopen_gisgeoservergeoserver_devprojectgeoserver20140305srcwebappsrcmainwebappdatagwc-layers  
  24. 05 三月 21:31:38 INFO [gwc.layer] - GWC configuration based on GeoServer""s Catalog loaded successfuly  
  25. 05 三月 21:31:38 INFO [layer.TileLayerDispatcher] - Configuration GeoServer Catalog Configuration contained no layers.  
  26. 05 三月 21:31:38 INFO [config.XMLConfiguration] - Found configuration file in C:UserssmartmapAppDataLocalTempgeowebcache  
  27. 05 三月 21:31:38 WARN [config.XMLConfiguration] - *******************************************************************  
  28. 05 三月 21:31:38 WARN [config.XMLConfiguration] - *** GWC configuration validation error: cvc-elt.1: 找不到元素 ""gwcConfiguration"" 的声明。  
  29. 05 三月 21:31:38 WARN [config.XMLConfiguration] - *** Will try to use configuration anyway. Please check the order of declared  
  30. elements against the schema.  
  31. 05 三月 21:31:38 WARN [config.XMLConfiguration] - ************************************************************  
  32. 05 三月 21:31:38 INFO [config.XMLConfiguration] - Initializing GridSets C:UserssmartmapAppDataLocalTempgeowebcache  
  33. 05 三月 21:31:38 INFO [config.XMLConfiguration] - Initializing layers C:UserssmartmapAppDataLocalTempgeowebcache  
  34. 05 三月 21:31:38 INFO [layer.TileLayerDispatcher] - Configuration C:UserssmartmapAppDataLocalTempgeowebcache contained no layers.  
  35. 05 三月 21:31:39 INFO [diskquota.ConfigLoader] - DiskQuota configuration not found: C:UserssmartmapAppDataLocalTempgeowebcache  
  36. geowebcache-diskquota.xml  
  37. 05 三月 21:31:39 INFO [diskquota.ConfigLoader] - DiskQuota configuration not found: C:UserssmartmapAppDataLocalTempgeowebcache  
  38. geowebcache-diskquota.xml  
  39. 05 三月 21:31:39 INFO [diskquota.DiskQuotaMonitor] - Setting up disk quota periodic enforcement task  
  40. 05 三月 21:31:39 INFO [diskquota.DiskQuotaMonitor] - 0 layers configured with their own quotas.  
  41. 05 三月 21:31:39 INFO [diskquota.DiskQuotaMonitor] - 0 layers attached to global quota 500.0 MB  
  42. 05 三月 21:31:39 INFO [diskquota.DiskQuotaMonitor] - Disk quota periodic enforcement task set up every 10 SECONDS  
  43. 05 三月 21:31:39 INFO [org.geoserver] - Loaded service ""wfs"", enabled  
  44. 05 三月 21:31:39 INFO [org.geoserver] - Loaded service ""wms"", enabled  
  45. 05 三月 21:31:39 INFO [org.geoserver] - Loaded service ""wcs"", enabled  
  46. 05 三月 21:31:39 INFO [gwc.config] - Initializing GeoServer specific GWC configuration gwc-gs.xml  
  47. 05 三月 21:31:39 INFO [ows.OWSHandlerMapping] - Mapped URL path [/gwc/service/**] onto handler ""dispatcher""  
  48. 05 三月 21:31:39 INFO [geowebcache.GeoWebCacheDispatcher] - Invoked setServletPrefix(gwc)  
  49. 05 三月 21:31:39 INFO [georss.GeoRSSPoller] - Initializing GeoRSS poller in a background job...  
  50. 05 三月 21:31:39 INFO [georss.GeoRSSPoller] - No enabled GeoRSS feeds found, poller will not run.  
  51. 05 三月 21:31:40 INFO [rest.RESTDispatcher] - Created RESTDispatcher with 14 paths  
  52. 05 三月 21:31:40 INFO [wms.WMSService] - Will NOT recombine tiles for non-tiling clients.  
  53. 05 三月 21:31:40 INFO [wms.WMSService] - Will proxy requests to backend that are not getmap or getcapabilities.  
  54. 05 三月 21:31:40 INFO [ows.OWSHandlerMapping] - Mapped URL path [/ows/**] onto handler ""dispatcher""  
  55. 05 三月 21:31:40 INFO [ows.OWSHandlerMapping] - Mapped URL path [/ows] onto handler ""dispatcher""  
  56. 05 三月 21:31:40 INFO [org.geoserver] - GeoServer configuration lock is enabled  
  57. 05 三月 21:31:41 INFO [ows.OWSHandlerMapping] - Mapped URL path [/wfs/*] onto handler ""dispatcher""  
  58. 05 三月 21:31:41 INFO [ows.OWSHandlerMapping] - Mapped URL path [/TestWfsPost] onto handler ""wfsTestServlet""  
  59. 05 三月 21:31:41 INFO [ows.OWSHandlerMapping] - Mapped URL path [/wfs] onto handler ""dispatcher""  
  60. 05 三月 21:31:45 INFO [ows.OWSHandlerMapping] - Mapped URL path [/wms/*] onto handler ""dispatcher""  
  61. 05 三月 21:31:45 INFO [ows.OWSHandlerMapping] - Mapped URL path [/wms] onto handler ""dispatcher""  
  62. 05 三月 21:31:46 INFO [ows.OWSHandlerMapping] - Mapped URL path [/animate] onto handler ""dispatcher""  
  63. 05 三月 21:31:46 INFO [ows.OWSHandlerMapping] - Mapped URL path [/animate/*] onto handler ""dispatcher""  
  64. 05 三月 21:31:46 INFO [ows.OWSHandlerMapping] - Mapped URL path [/wcs] onto handler ""dispatcher""  
  65. 05 三月 21:31:46 INFO [ows.OWSHandlerMapping] - Mapped URL path [/wcs/**] onto handler ""dispatcher""  
  66. 05 三月 21:31:47 INFO [ows.OWSHandlerMapping] - Mapped URL path [/kml] onto handler ""dispatcher""  
  67. 05 三月 21:31:47 INFO [ows.OWSHandlerMapping] - Mapped URL path [/kml/*] onto handler ""dispatcher""  
  68. 05 三月 21:31:47 INFO [ows.OWSHandlerMapping] - Mapped URL path [/kml/icon/**/*] onto handler ""kmlIconService""  
之后在浏览器中打开:http://localhost:8080/geoserver/,如下:

原文地址:https://www.cnblogs.com/zhaoyanhaoBlog/p/9026620.html