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

您所在的位置:网站首页 thingsboard编译安装 ThingsBoard 3.0 本地环境搭建和源码编译安装

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

2024-04-14 02:56| 来源: 网络整理| 查看: 265

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

环境安装

开发环境要求:

Jdk 1.8 版本 ;Postgresql 9 以上;Maven 3.6 以上;Git 工具;Idea 开发工具;Redis;Node.js,npm;

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

thingsboard 安装步骤

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

获取 thingsboard 代码

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

1git clone -b release-3.0 https://github.com/thingsboard/thingsboard.gitmaven 镜像源配置

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

12345678           nexus-aliyun        central          Nexus aliyun        https://maven.aliyun.com/repository/public    npm 镜像源配置12npm config set registry https://registry.npm.taobao.org       #使用淘宝镜像npm config get registry       #查询当前镜像IDEA 导入 thingsboard

导入后,先使用maven工具清理项目编译文件。ThingsBoard 3.0 本地环境搭建和源码编译安装_thingsboard导入IDEA后,需要改下pom文件里面的node和npm版本与你本地的一致。如图:ThingsBoard 3.0 本地环境搭建和源码编译安装_thingsboard_02注意!!!!thingsboard 3.1版本包管理换成了yarn,因此要看清pom文件的xml标签,yarnVersion对应yarn的版本。ThingsBoard 3.0 本地环境搭建和源码编译安装_物联网_03

改完之后可以去掉license检查步骤,节省编译时间。ThingsBoard 3.0 本地环境搭建和源码编译安装_物联网_04

开始编译

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

1mvn clean install -DskipTests

ThingsBoard 3.0 本地环境搭建和源码编译安装_物联网_05等一段时间后,看到下面这张图就算编译成功,如果没有编译成功请按照本教程最后的常见问题进行排查。ThingsBoard 3.0 本地环境搭建和源码编译安装_iot_06

常见问题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 这两个文件。解决办法:

下载这两个文件到本地,下载后记得重命名,下载地址:Github地址如何github上的这几个文件下载很慢,可以直接使用csdn下载,链接如下:fetched-v10.17.0-win-x64fetched-v10.17.0-linux-x64fetched-v10.15.3-win-x64fetched-v10.15.3-linux-x64

如何你的csdn没有积分,可直接在物联工坊免费下载,链接如下:fetched-v10.17.0-win-x64fetched-v10.17.0-linux-x64fetched-v10.15.3-win-x64fetched-v10.15.3-linux-x64

下载完成后,放到C盘用户下的.pkg目录,如图:ThingsBoard 3.0 本地环境搭建和源码编译安装_物联网_07npm: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 c ode 1) -> [Help 1]

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

Build 找不到类或符号

编译前需要安装proto和lombok插件,可直接在插件市场安装,如图:ThingsBoard 3.0 本地环境搭建和源码编译安装_thingsboard_08安装完成后重启idea进行编译。如果是2020版本的idea,可能还会报找不到符号之类的错误,这个时候需要清理下缓存重启idea:ThingsBoard 3.0 本地环境搭建和源码编译安装_thingsboard_09还报这个错误的话,需要重置下idea的配置:ThingsBoard 3.0 本地环境搭建和源码编译安装_thingsboard_10

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

解决:将已经安装的C:\Program Files\nodejs\node.exe(node的安装路径)复制到maven本地仓库F:\share\local_repo\com\github\eirslett\node\12.18.2(本地仓库的node目录,版本号自行对应,名称自行修改)

[ERROR] PROTOC FAILED[ERROR] PROTOC FAILED:...\thingsboard\common\message\src\main\proto\tbmsg.proto: No such file or directory

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

结语

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

本文转载自“物联工坊”,原文地址:https://meimos.com/course/platform/109.html。物联工坊



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3