主页 > IT业界  > 

Mac下ThingsBoard本地源代码安装和运行

Mac下ThingsBoard本地源代码安装和运行
1、前言

讲解在Mac环境下,ThingsBoard本地源代码安装和运行的过程和问题的解决

2、ThingsBoard中文网文档

安装的文档主要借鉴ThingsBoard中文网文档:

源代安装 | ThingsBoard社区版http:// .ithingsboard /docs/user-guide/install/building-from-source/#%E5%AE%89%E8%A3%85%E5%8C%85

3、前置环境

为了还原实际部署可能遇到的问题,我使用的是本机已下载的环境展开讲解。

3.1、Java版本

11.0.18

3.2、Maven版本

3.9.5

3.3、node版本

v21.5.0

3.3.1、node版本切换

如果node版本有报错过低,则可以切换版本,node版应该至少v16.5.0。

3.3.3.1、安装node版本管理模块 // 安装方式以下三选一 // 使用 npm sudo npm install n -g // yarn yarn global add n // 使用 brew brew install n 3.3.3.2、管理模块指定node版本 sudo n 版本

3.4、npm版本

10.2.4

3.5、yarn版本

4、安装编译 4.1、克隆代码

clone成功后,先不要去编辑器中运行,最好先命令(控制台命令)编译好,因为需要下载很多依赖,编译安装的过程中也会生成一些类,直接打开会报错。

git clone github /thingsboard/thingsboard.git cd thingsboard 4.2、编译运行

在thingsboard项目目录下运行maven install指令开始编译安装:

mvn clean install -DskipTests 4.3、出现的编译失败 4.3.1、报错内容

[INFO] --- frontend:1.12.0:yarn (yarn pkg) @ web-ui --- [INFO] Running 'yarn run pkg' in /Users/lidongbin/code/java/thingsboard/msa/web-ui [INFO] yarn run v1.22.17 [INFO] $ tsc && pkg -t node16-linux-x64,node16-win-x64 --out-path ./target ./target/src && node install.js [INFO] > pkg@5.7.0 [INFO] > Fetching base Node.js binaries to PKG_CACHE_PATH [INFO] > Not found in remote cache: [INFO]   {"tag":"v3.4","name":"node-v16.15.0-linux-x64"} [INFO] > Building base binary from source: [INFO]   built-v16.15.0-linux-x64 [INFO] > Error! Not able to build for 'linux' here, only for 'macos' [INFO] info Visit yarnpkg /en/docs/cli/run for documentation about this command.

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:yarn (yarn pkg) on project web-ui: Failed to run task: 'yarn run pkg' failed. org.apache mons.exec.ExecuteException: Process exited with an error: 2 (Exit value: 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 <args> -rf :web-ui

4.2.2、报错问题

pkg-cache下没有对应mac版本的node16.5.0版本的pkg相关文件。

4.2.3、问题解决

我们可以通过下载对应的pkg-cache相关文件来避免此错误。

4.2.3.1、切换版本

参考3.3.1、node版本切换

4.2.3.2、pkg-cache相关文件下载和使用

pkg-cache相关文件下载地址(vercel/pkg-fetch · GitHub)A utility to fetch or build patched Node binaries used by `pkg` to generate executables. This repo hosts prebuilt binaries in Releases. - Releases · vercel/pkg-fetch github /vercel/pkg-fetch/releases找到node16.5.0版本的assets,将linux,macos,win都下载(其实在mac下只需要macos)。

将下载后的文件,重命名为

将node-v16.15.0-macos-x64更名为fetched-v16.15.0-macos-x64将node-v16.15.0-linux-x64更名为fetched-v16.15.0-linux-x64将node-v16.15.0-win-x64更名为fetched-v16.15.0-win-x64

然后放入~\.pkg-chche\3.4目录中。

 4.2.3.3、重新编译 mvn clean install -DskipTests

5、运行

在IDEA中打开项目,并修改thingsboard.yml中数据库相关配置,替换用户名密码。

将dao模块下,sql文件拷贝至application模块data/sql目录中

运行 ThingsboardInstallApplication,完成thingsboard表结构和数据的初始化。默认情况下,使用系统管理员sysadmin@thingsboard.org,sysadmin进行登录 。当然,初始化用户可以在配置文件中自定义。

接着运行ThingsboardServerApplication,访问http://localhost:8080/ 自动跳转至登录页面

标签:

Mac下ThingsBoard本地源代码安装和运行由讯客互联IT业界栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“Mac下ThingsBoard本地源代码安装和运行