【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:执行编译命令报错

编译命令:

mvn clean install -Dmaven.test.skip=true

报错如下:

[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:替换编译命令

mvn clean install -DskipTests

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

在这里插入图片描述
再执行编译命令

mvn clean install -Dmaven.test.skip=true
### 或
mvn clean install -DskipTests

报错2:gradle下载不了

[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 命令:

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 的问题之后,再次执行编译命令:

mvn clean install -Dmaven.test.skip=true
### 或
mvn clean install -DskipTests

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

[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模块的依赖问题

[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

在这里插入图片描述
注释掉这些引用,再次执行编译命令:

mvn clean install -Dmaven.test.skip=true
### 或
mvn clean install -DskipTests

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

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

[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/#%E7%BB%8F%E9%AA%8C%E6%80%BB%E7%BB%93
在这里插入图片描述
提醒一下,官网这个解决方案的源码版本是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

  • 22
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值