个人尝试本地部署Graphhopper路径规划引擎的过程基本参考本地部署Graphhopper实现离线地图路径规划功能(小白放心食用版)。
本文主要是对整个过程从环境配置到服务部署的过程以及遇到的问题进行了记录。有些问题在参考的博客中有记录,本文并未完全移植,而是根据部署过程中遇到的其他问题进行了记录和解决。
部署过程中遇到的问题可以参照本文和参考博文记录的问题进行解决,希望能起到作用,有不足的地方也请指出。
特别说明:使用的是graphhopper的stable分支
获取方式
git clone -b stable https://github.com/graphhopper/graphhopper.git
CLASSPATH
;变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
大体步骤如下:
....... JDK-1.8 true 1.8 1.8 1.8 1.8 ........
...... alimaven aliyun maven http://maven.aliyun.com/nexus/content/groups/public/ central .......
...... D:\Program Files\Java\mvn-repository ......
地图数据下载地址,可以根据根据需要下载,我下载的中国的数据,有1g过,后面构建运行的时候还挺耗时的。
我将china-latest.osm.pbf
放在了源码项目的根目录了
config-example.yml
datareader.file: "./china-latest.osm.pbf" # Local folder used by graphhopper to store its data graphhopper.flag_encoders: car graph.location: graph-cache http.port: 8989
./graphhopper.sh build
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.10.0:install-node-and-npm (install node and npm) on project graphhopper-web: Could not download npm: Could not download https://registry.npmjs.org/npm/-/npm-6.14.5.tgz: Read timed out -> [Help 1]
解决办法:打开graphhoper项目文件夹下的pom.xml文件,在plugins标签内添加如下配置,就是更改了npm源为淘宝最新的npm源,如果不行的话尝试一下科学上网
com.github.eirslett frontend-maven-plugin 1.6 install node and npm install-node-and-npm http://nodejs.org/dist/ https://registry.npmmirror.com
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.10.0:install-node-and-npm (install node and npm) on project graphhopper-web: Could not extract the npm archive: Could not extract archive: 'D:\Program Files\Java\mvn-repository\com\github\eirslett\npm\6.14.5\npm-6.14.5.tar.gz': EOFException -> [Help 1]
解决办法:删除...\com\github\eirslett\
目录下的eirslett文件夹,然后执行mvn clean install
参考文章Could not extract the npm archive (using frontend-maven-plugin 1.3) #545
执行命令:./graphhopper.sh -a web -i ./china-latest.osm.pbf
解决办法:export JAVA_OPTS="-Xmx4g -Xms4g"#加大至4G内存
因为要解析地图数据,会耗费大概15分钟左右,很多人在浏览器输入http://127.0.0.1:8989,网页一直打转,没有立马加载出来,是因为服务还没有完全启动,很多博客忽略这个环节,启动成功的标志是