文章目录
- 一,需要准备的环境
- 二,获取tingsboard源码
- 1.git拉取源码
- 2.下载源码压缩包
 
- 三.新建仓库存放依赖文件
- 四,编译
- 五,遇到的错误
提示:
 1.这篇只要准备两个环境,方法更简单!
 2.基于tingsboard 3.6.3
 3. 建议软件不要安装在C盘,会涉及权限问题。
 4,需要梯子下载的更快,不然很复杂
 5,可以参考官网教程
一,需要准备的环境
1.JDK11(不一定要用openjdk)
 2.maven (版本:apache-maven-3.6.3)
可以看到是maven用的是java11:
 
 这是我的一些环境变量路径:
 
 用户变量:
 
 系统变量:
 
 PATH:
 
 (因为找了很多资料改了很多次,我也不知道标准的环境变量配置应该是怎么样的,可以去找一些其他写的清楚的,也可以参考我的上一篇看这两个环境的搭建)
二,获取tingsboard源码
介绍两种方法:
1.git拉取源码
- 进入thingsboard的官网:点此,找到github地址
  
 复制下面链接到git控制台上进行克隆
  
 右击:
  
 输入:
git clone https://github.com/thingsboard/thingsboard.git

 成功拉取源代码。
- 直接拉可能拉的源码不稳定,有的可能还在更新中,所以可以切换分支进行拉取更好:
  
2.下载源码压缩包
不用切换分支,直接下载源码:
- 点击tags

- 选择releases

- 往下滑:
  
 下载到指定目录。
三.新建仓库存放依赖文件
-  解压下载下来的tingsboars压缩包 
-  新建文件夹,在本地存放依赖文件,方便后续查看 
  
-  复制本地仓库maven-repository的路径  
-  将settings.xml打开(或者用编译软件打开,排列更整齐,更方便看) 
  
-  将 <localRepository>/path/to/local/repo</localRepository>复制一句。
 改为:<localRepository>D:\project\maven-repository</localRepository>(将/path/to/local/repo替换成刚刚复制的本地仓库路径D:\project\maven-repository)
  
-  镜像改为阿里云的,下载更快 
<!-- 阿里云仓库 --><mirror><id>alimaven</id><name>aliyun maven</name><url>http://maven.aliyun.com/nexus/content/repositories/central/</url><mirrorOf>central</mirrorOf></mirror><!-- 中央仓库1 --><mirror><id>repo1</id><mirrorOf>central</mirrorOf><name>Human Readable Name for this Mirror.</name><url>http://repo1.maven.org/maven2/</url></mirror></mirrors>

 保存。
四,编译
-  进入thingsboard-3.6.3的目录下 
  
-  输入cmd 
-  打开官网: 
-  复制语句 mvn clean install -DskipTests
  
-  输入下列语句更快: 
mvn -T 0.8C clean install -DskipTests

- 编译成功:
  
五,遇到的错误
- Failed to execute goal com.mycila:license-maven-plugin:3.0:check (default)
[ERROR] Failed to execute goal com.mycila:license-maven-plugin:3.0:check (default) on project thingsboard: Some files do not have the expected license header -> [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/MojoExecutionException

 解决办法:输入mvn license:format再编译即可。
mvn license:format
参考资料: https://b23.tv/N20hI8G