物联网-thingsboard源码编译安装踩坑记录

Maven编译与Git配置升级问题:从源码到部署的解决方案
本文详细讲述了在克隆源码后遇到的Maven编译错误,涉及版本兼容、git安全设置、JDK CLASSPATH问题及数据库连接配置。通过解决步骤,助你成功搭建ThingsBoard环境。

前言

深夜踩坑真艰难,但获得的成就感也是最开心的~

从 GitHub 上 Clone 下源码后运行 Mavan 报错

如果运行 mvn clean install -DskipTests --settings D:\scoop\apps\maven\current\conf\thingsboardSettings.xml 命令后编译报错,最大的可能就是 jdk 的版本和仓库的版本不符,目前仓库最新的代码(thingsboard-3.3.1)用的 jdk 是 jdk11,而我电脑上安装的是 jdk8,所以这肯定就编译不过了。解决办法就是去 GitHub Release 找到 ThingsBoard 3.2.1 Release 下载,注意选择源码版本下载,如下图。3.2.1 版本的 thingsboard 是用的 jdk8,然后在运行 mvn 命令就不会报编译错误了。

ThingsBoard 3.2.1 Release

thingsboardSettings.xml 文件内容放到文章附录,需要的自取。注意将文件中的 <localRepository>D:\RepMaven</localRepository> 改成自己的路径

报错 The unauthenticated git protocol on port 9418 is no longer supported.

报错如下图

哎,这个就是由于最新版本的 git 提升安全性加入了新特性(2022.1.11)导致的

解决办法就是在 .gitconfig 文件中加入如下语句

[url "https://"]
  insteadOf = ssh://
[url "https://"]
  insteadOf = git://

然后重新进行编译即可~~

参考链接:The unauthenticated git protocol on port 9418 is no longer supported.

Cannot resolve com.sun:tools:1.4.2

报错图

这个问题真是太坑了,因为我的 jdk8 是通过 scoop 安装的,而这个工具安装的 jdk8 没有配置 CLASSPATH 环境变量,导致找不到 com.sun:tools

解决办法就是在环境变量里配置一下 CLASSPATH 为 .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar,如下图。

配置环境变量

配置完成后再在 IDEA 里打开项目,点击侧边栏 Maven 下方的刷新按钮,刷新完成后项目就不再报错啦~

项目就不再报错啦

org.postgresql.util.PSQLException: 不支援 10 验证类型。请核对您已经组态 pg_hba.conf 文件包含客户端的IP位址或网路区段,以及驱动程序所支援的验证架构模式已被支援

运行数据库初始化脚本 install_dev_db.bat 报错。感谢这位老哥的帖子给出了解决方案

解决办法:找到 pgsql 的安装目录下的 pg_hba.conf 文件,如下图

pg_hba.conf

用文本编辑器打开后做如下修改

# "local" is for Unix domain socket connections only
local   all             all                           trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

修改示意图

修改完成后,再次运行 install_dev_db.bat 脚本就不会报错啦~

数据库初始化成功

参考链接

附录

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Apple_Coco

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值