confluence安装_ThingsBoard 3.0 本地环境搭建和源码编译安装

本章将介绍ThingsBoard的本地环境搭建,以及源码的编译安装。本机环境:jdk1.8、postgresql-12.2-2-windows-x64、maven 3.6.2、node v12.18.2、idea 2020.1、redis 3.2。

环境安装

开发环境要求:

  1. Jdk 1.8 版本 ;
  2. Postgresql 9 以上;
  3. Maven 3.6 以上;
  4. Git 工具;
  5. Idea 开发工具;
  6. Redis;
  7. Node.js,npm;

上述条件满足后,接下来是通过 Git 拉取代码。

thingsboard 安装步骤

温馨提醒:由于网络原因等因素,若安装过程中失败,建议先清空maven本地仓库的jar以及ui-ngx工程下的node_modules目录。然后再执行下面操作。

获取 thingsboard 代码

在本地创建代码存放位置的文件目录,然后进入当前目录点击鼠标右键,选择 Git Bash Here,输入 git 命令克隆源代码。本章节以3.0版本为例。

git clone -b release-3.0 https://github.com/thingsboard/thingsboard.git

maven 镜像源配置

由于默认仓库地址的下载速度很慢,因此使用阿里云的镜像会节省很多时间。maven conf目录下的settings.xml配置如下:

 nexus-aliyuncentralNexus aliyunhttps://maven.aliyun.com/repository/public

npm 镜像源配置

npm config set registry https://registry.npm.taobao.org       #使用淘宝镜像npm config get registry       #查询当前镜像

IDEA 导入 thingsboard

导入后,先使用maven工具清理项目编译文件。

5a2ba07d5255fafe7a007dafe1bb3d67.png


导入IDEA后,需要改下pom文件里面的node和npm版本与你本地的一致。如图:

3623bb7aeacd76c8a671d9f3e8f8c292.png

注意!!!!thingsboard 3.1版本包管理换成了yarn,因此要看清pom文件的xml标签,yarnVersion对应yarn的版本。

6ad4884506ff61182546ab087be6caaa.png

改完之后可以去掉license检查步骤,节省编译时间。

b8c41238804a61c1dab20f64f5be58c7.png

开始编译

在 IDEA 控制台(左下方)Terminal 输入以下命令进行编译:

mvn clean install -DskipTests
e0237ba7bc55ca0ef703697991449e9d.png


等一段时间后,看到下面这张图就算编译成功,如果没有编译成功请按照本教程最后的常见问题进行排查。

d65d974194d69894eb5aa6661af24b74.png

常见问题

JavaScript Executor 编译失败

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0:npm (npm install) on project js-executor: Failed to run task: 'npm install' failed. (error code 2) -> [Help 1][ERROR][ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR][ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException[ERROR][ERROR] After correcting the problems, you can resume the build with the command[ERROR]   mvn  -rf :js-executor

原因:本地缓存缺少 fetched-v10.15.3-linux-x64 和 fetched-v10.15.3-win-x64 或 fetched-v10.17.10-linux-x64 和 fetched-v10.17.10-win-x64 这两个文件。
解决办法:

  1. 下载这两个文件到本地,下载后记得重命名,下载地址:https://meimos.com/download/tools
    文件名如下:
    fetched-v10.17.0-win-x64
    fetched-v10.17.0-linux-x64
    fetched-v10.15.3-win-x64
    fetched-v10.15.3-linux-x64
  2. 下载完成后,放到C盘用户下的.pkg目录,如图:

npm:npm ERR! path git

[ERROR] npm ERR! code ENOGIT[ERROR] npm ERR! No git binary found in $PATH[ERROR] npm ERR![ERROR] npm ERR! Failed using git.[ERROR] npm ERR! Please check if you have git installed and in your PATH.[ERROR][ERROR] npm ERR! A complete log of this run can be found in:[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0:npm(npm install) on project ui: Failed to run task: 'npm install' failed. (error code 1) -> [Help 1]

原因:没有安装git或者是没有配置git的环境变量

Build 找不到类或符号

编译前需要安装proto和lombok插件,可直接在插件市场安装,如图:

07cf691afad5f33e2dc45ebf3550aecb.png


安装完成后重启idea进行编译。如果是2020版本的idea,可能还会报找不到符号之类的错误,这个时候需要清理下缓存重启idea:

a965c038a8919bca1ddef50a37ce3d84.png


还报这个错误的话,需要重置下idea的配置:

f90fae73ffdb892ededba422f068506f.png

node 不是有效的 Win32 应用程序

Failed to run task: 'npm install' failed. java.io.IOException: Cannot run program "E:githingsboardui-ngxargetodeode.exe" (indirectory "E:githingsboardui-ngx"): CreateProcess error=193, %1 不是有效的 Win32 应用程序。 -> [Help 1]

解决:将已经安装的C:Program Filesodejsode.exe(node的安装路径)复制到maven本地仓库F:sharelocal_repocomgithubeirslettode12.18.2(本地仓库的node目录,版本号自行对应,名称自行修改)

[ERROR] PROTOC FAILED

[ERROR] PROTOC FAILED:...hingsboardcommonmessagesrcmainprotobmsg.proto: No such file or directory

原因:thingsboard 项目地址不支持中文。
解决:将项目转移到全英文路径

结语

自己在编译Thingsboard 3.0也遇到了很多麻烦,在此总结一下,也希望可以帮助到更多的小伙伴,避免和我踩一样的坑。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值