【ThingsBoard初体验】本地编译踩坑记录

前言

这只是我自己的踩坑记录,以尽快启动项目为主,暂时不对编译出现的问题做深入分析。

第一次接触物联网项目,对于文章出现的问题,如果能帮到其他小伙伴,那是我的荣幸。

大佬们有更好的解决办法,也希望能够指点指点~

本机环境

JDK:17

Node:12.22.11

Maven:3.6.3

idea:最新社区版

ThingsBoard源码:3.7.1-SNAPSHOT

本机系统:Windows 10 专业版

官网编译教程:http://www.ithingsboard.com/docs/user-guide/contribution/yuanmabianyi/

报错1:执行编译命令报错

编译命令:

powershell 复制代码
mvn clean install -Dmaven.test.skip=true

报错如下:

java 复制代码
[ERROR] Unknown lifecycle phase ".test.skip=true". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugi
n-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resourc
es, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, 
prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/LifecyclePhaseNotFoundException

解决办法

方案1:替换编译命令

powershell 复制代码
mvn clean install -DskipTests

方案2:idea的默认终端切换为Command Prompt

再执行编译命令

powershell 复制代码
mvn clean install -Dmaven.test.skip=true
### 或
mvn clean install -DskipTests

报错2:gradle下载不了

java 复制代码
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  43.022 s
[INFO] Finished at: 2024-07-29T00:07:59+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.thingsboard:gradle-maven-plugin:1.0.12:invoke (default) on project http: Execution default of goal org.thingsboard:gradle-maven-plu
gin:1.0.12:invoke failed: Plugin org.thingsboard:gradle-maven-plugin:1.0.12 or one of its dependencies could not be resolved: Failure to find org.gradle:gradle-tooling-api:jar:7.3.3 in http://maven.aliyun.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus-aliyun has elapsed or updates are forced -> [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/PluginResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf org.thingsboard.transport:http


从报错信息可以看出是gradle弄不下来,根据网上搜索到的解决方案:

1、修改maven镜像为淘宝镜像

2、挂梯子
以上方案均不成功

最终解决办法:手动安装依赖包

https://mvnrepository.com/ 搜索 gradle-tooling-api 直接下载对应版本的 jar 包,通过 maven 命令手动安装到本地仓库的方式解决。

7.3.3版本地址:https://mvnrepository.com/artifact/org.gradle/gradle-tooling-api/7.3.3

直接下载:https://repo.gradle.org/gradle/libs-releases/org/gradle/gradle-tooling-api/7.3.3/gradle-tooling-api-7.3.3.jar

提醒一下,需要根据源码版本下载对应的gradle版本:

下载 jar 之后,执行 maven 命令:

powershell 复制代码
mvn install:install-file "-Dmaven.repo.local=D:\maven\repository(本地maven仓库路径)" "-DgroupId=org.gradle" "-DartifactId=gradle-tooling-api" "-Dversion=7.3.3" "-Dpackaging=jar" "-Dfile=C:\Users\Downloads\gradle-tooling-api-7.3.3.jar(下载的jar包所在的路径)"

解决了下载不了 gradle-tooling-api:jar:7.3.3 的问题之后,再次执行编译命令:

powershell 复制代码
mvn clean install -Dmaven.test.skip=true
### 或
mvn clean install -DskipTests

报错3:编译时无法识别gradle

java 复制代码
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:17 min
[INFO] Finished at: 2024-07-29T00:18:37+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.thingsboard:gradle-maven-plugin:1.0.12:invoke (default) on project http: org.gradle.tooling.BuildException: Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.3.3-bin.zip'. -> [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 org.thingsboard.transport:http


这个问题,我最开始解决办法是修改idea默认的gradle路径为指定版本路径:

❌❌❌虽然能解决,但是指定了gradle版本路径,可能会导致其他项目使用其他gradle版本的话,就会识别不到,所以不建议尝试这个办法!

最终解决办法:重启大法

重启电脑,发现使用默认路径也能成功!

可能是因为当时手动安装了gradle,导致idea没有立即识别到的原因。
所以遇到这个问题的小伙伴,可以尝试先重启一下电脑看看能不能解决这个问题。

报错4:ui-ngx模块的依赖问题

java 复制代码
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:05 min
[INFO] Finished at: 2024-07-29T18:51:37+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project application: Could not resolve dependencies for project org.thingsboard:application:jar:3.7.1-SNAPSHOT: Failed to collect de
pendencies at org.thingsboard:ui-ngx:jar:3.7.1-SNAPSHOT: Failed to read artifact descriptor for org.thingsboard:ui-ngx:jar:3.7.1-SNAPSHOT: Could not transfer artifact org.thingsboard:ui-ngx:pom:3.7.1-SNAPSHOT from/to spring-snapshots (https://repo.spring.io/snapshot): Transfer failed for https://repo.spring.io/snapshot/org/thingsboard/ui-ngx/3.7.1-SNAPSHOT/ui-ngx-3.7.1-SNAPSHOT.pom: Connection reset -> [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/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :application

解决办法:由于我不使用这个项目原本的前端模块,所以我解决这个问题的办法就是把ui-ngx这个模块在项目的依赖关系中直接踢除掉

需要使用项目原本的前端的小伙伴,看到这里就可以跳过这个问题了,因为解决方案对你已经无用了。

请自行百度解决方案哈!

可以看到这里报错是无法解析 ui-ngx 这个模块依赖的问题,但一开始我们就已经把 ui-ngx 在 父pom 中已经注释掉了,可还是出现了这个问题,那就说明在别的模块中也引入了 ui-ngx 。

在idea全局搜索发现,确实在别的模块中引用了 ui-ngx

注释掉这些引用,再次执行编译命令:

powershell 复制代码
mvn clean install -Dmaven.test.skip=true
### 或
mvn clean install -DskipTests

好家伙,还是编译失败!!!也就是【报错5】↓↓↓

报错5:爆出个yarn下载失败???

java 复制代码
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:install-node-and-yarn (install node and yarn) on project js-executor: Could not download Yarn: Could not download https://github.com/yarnpkg/yarn/releases/download/v1.22.17/yarn-v1.22.17.tar.gz: Connection reset -> [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 :js-executor

搞到这里,解决方案就不用再费心思百度了,按照官网来,但还是要先确认一下需要的文件版本

解决方案:参考官网的来

官网地址:http://www.ithingsboard.com/docs/user-guide/contribution/yuanmabianyi/#经验总结

提醒一下,官网这个解决方案的源码版本是2.6,如果拉取的是最新源码,需要在报错信息中搜索"yarn",找到当前版本源码需要的文件版本

https://github.com/vercel/pkg-fetch/releases 找到 v3.4,下载需要的文件放到对应的 .pkg-cache 目录中(没有.pkg-cache目录,就自己创建一下)

文件下载下来之后,就参考官网的方案操作吧!

不想去github翻找这个文件的话,也可以点击下面链接直接下载

node-v16.15.0-win-x64:https://github.com/vercel/pkg-fetch/releases/download/v3.4/node-v16.15.0-win-x64

node-v16.15.0-linux-x64:https://github.com/vercel/pkg-fetch/releases/download/v3.4/node-v16.15.0-linux-x64

到此!ThingsBoard源码本地编译踩坑之旅就结束了,终于结束了!φ(゜▽゜*)♪


附上编译成功截图表示庆祝!!!O(∩_∩)O

相关推荐
Chrikk1 小时前
Go-性能调优实战案例
开发语言·后端·golang
幼儿园老大*1 小时前
Go的环境搭建以及GoLand安装教程
开发语言·经验分享·后端·golang·go
canyuemanyue1 小时前
go语言连续监控事件并回调处理
开发语言·后端·golang
杜杜的man1 小时前
【go从零单排】go语言中的指针
开发语言·后端·golang
测开小菜鸟1 小时前
使用python向钉钉群聊发送消息
java·python·钉钉
P.H. Infinity2 小时前
【RabbitMQ】04-发送者可靠性
java·rabbitmq·java-rabbitmq
生命几十年3万天2 小时前
java的threadlocal为何内存泄漏
java
caridle3 小时前
教程:使用 InterBase Express 访问数据库(五):TIBTransaction
java·数据库·express
^velpro^3 小时前
数据库连接池的创建
java·开发语言·数据库
苹果醋33 小时前
Java8->Java19的初步探索
java·运维·spring boot·mysql·nginx