Thingsboard 源码编译及安装
一、环境检查
要想不踩坑,一定要认认真真检查自己电脑环境 本次演示使用Windows系统,其它系统大同小异,最主要的是一定要好好检查自己的环境。 涉及的工具及中间件有(最基本):
Nodejs
、Java 11
、maven
、Git
、Redis
、postgresql
1. Nodejs
因为thingsboard项目中自带了Nodejs,如果系统没有安装过nodejs,tb会默认使用项目中自带的
如果系统中安装过nodejs,一定要注意一下版本(ui-ngx 模块下的pom文件,根据pom文件来下载对应的nodejs版本)
$ node -v
v16.13.2
$ # 如果没问题建议修改一下node远程仓库地址
$ npm config set registry https://registry.npm.taobao.org
2. Java 11
官网下载 | jdk-11.0.13_windows-x64_bin.exe
$ java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment Temurin-11.0.13+8 (build 11.0.13+8)
OpenJDK 64-Bit Server VM Temurin-11.0.13+8 (build 11.0.13+8, mixed mode)
3. maven
官网下载 | apache-maven-3.8.6-bin.zip
# 不重要,用最新的即可
$ mvn -v
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /usr/local/Cellar/maven/3.8.1/libexec
Java version: 15.0.2, vendor: N/A, runtime: /usr/local/Cellar/openjdk/15.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: zh_CN_#Hans, platform encoding: UTF-8
OS name: "mac os x", version: "12.6", arch: "x86_64", family: "mac"
修改maven仓库
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
4. Git
官网下载 用最新的即可
# 配置
# 代理服务器地址
git config --global url."https://new-url/".insteadOf https://
# 回退
git config --global --unset url."https://".insteadOf
如果没有代理服务器,本站提供了一个高效的代理服务器,您需要支付一笔很少的费用,即可使用
5. Redis
Github 下载 用最新的即可
6. postgresql
官网下载 用最新的即可
# 默认的账号密码是:postgres
二、下载源码
- 从Github上下载 https://github.com/thingsboard/thingsboard.git
- 从Gitee上下载 https://gitee.com/javabase-rd/thingsboard.git
三、开始安装
如果你是在编译ui-ngx模块出现了问题,请直接跳转到:四、编译ui-ngx
进入Thingsboard目录执行mvn clean -DskipTests=True install
开始安装
这个过程比较慢,需要耐心等待
在安装的过程中会遇到一些问题,我在此列举一下:
# windows 最好先刷新一下dns
ipconfig/flushdns
刷新完成后退出powershell再次执行命令安装
[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_PAT
# 进入目录:
cd ~/.pkg-cache/
# 选择node版本,我的是v3.4
cd v3.4
根据还没下载下来的半个文件,下载对于的版本:
ls
... fetched-v16.15.0-linux-x64.downloading
# 或者,修改hosts
8.217.18.112 objects.githubusercontent.com
官网地址 选择需要下载的版本,我的版本是v16.15.0 下载完成后把名字改为对应的: fetched-v16.15.0-linux-x64 fetched-v16.15.0-win-x64
fatal: unable to access 'https://github.com/xxx/demo.git/': SSL certificate problem: unable to get local issuer certificate
解决方法,执行以下命令,执行完成后关闭终端重新打开
git config --global http.sslVerify false
下载失败
这里你需要把当前的网络换成4G或者多试几次
四、编译ui-ngx
遇到这种问题大多都是因为网络原因导致的。如果是因为下载依赖失败请尝试,修改node源,修改方式:
进入\ui-ngx\pom.xml
文件找到插件frontend-maven-plugin
在这里配置国内源,配置如下:
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<configuration>
<installDirectory>target</installDirectory>
<workingDirectory>${basedir}</workingDirectory>
<nodeDownloadRoot>https://npmmirror.com/mirrors/node/</nodeDownloadRoot>
<npmDownloadRoot>https://npmmirror.com/mirrors/npm/</npmDownloadRoot>
</configuration>
<executions>
<execution>
<id>yarn build</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>run build:prod</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
https://npmmirror.com/mirrors/node/ 、https://npmmirror.com/mirrors/npm/ 就是添加的源
第二步骤:
<arguments>install --non-interactive --network-concurrency 4 --network-timeout 100000 --mutex network --proxy=你的代理地址</arguments>
问题
error:1E08010C:DECODER
这个问题一般是ssl导致的,我的解决方式是在ui-gnx模块中的pom.xml文件中修改
<arguments>install --non-interactive --network-concurrency 4 --network-timeout 100000 --mutex network</arguments>
改为:
<arguments>install --non-interactive --network-concurrency 4 --network-timeout 100000 --mutex network --strict-ssl false --verbose</arguments>
其中--strict-ssl false --verbose 是取消ssl校验 并且打印详细内容,如果还不行那就先清除一下缓存,改为:
<arguments>cache clean</arguments>
执行完成后,不用管报错,再把arguments改为原始状态,再次编译
傻瓜式安装方式
依赖下载地址:
联系我,微信:122811041 (添加时注明来意)