网上有很多资料,每个人遇到的情况也都不一样。本人成功编译花费将近一周时间,过程整理如下:

1、下载GIT源码

  1. 目录右键,选择Git Bash Here
  2. 输入git命令克隆源代码:
git clone https://github.com/thingsboard/thingsboard.git
  1. 进入thingsboard文件夹:
cd thingsboard
git branch
  1. 列出所有版本:
git branch -a
  1. checkout 最新realease版本
git checkout realease-3.1

2、编译准备

  1. 注释插件
    打开项目源码中的文件,查看其中的检查插件,打开thingsboard跟目录,pom.xml,查找license-maven-plugin,并注释掉
<!--<plugin><groupId>com.mycila</groupId><artifactId>license-maven-plugin</artifactId><version>3.0</version><configuration><header>${main.dir}/license-header-template.txt</header><properties><owner>The Thingsboard Authors</owner></properties><excludes><exclude>**/.env</exclude><exclude>**/*.env</exclude><exclude>**/.eslintrc</exclude><exclude>**/.babelrc</exclude><exclude>**/.jshintrc</exclude><exclude>**/.gradle/**</exclude><exclude>**/nightwatch</exclude><exclude>**/README</exclude><exclude>**/LICENSE</exclude><exclude>**/banner.txt</exclude><exclude>node_modules/**</exclude><exclude>**/*.properties</exclude><exclude>src/test/resources/**</exclude><exclude>src/vendor/**</exclude><exclude>src/font/**</exclude><exclude>src/sh/**</exclude><exclude>packaging/*/scripts/control/**</exclude><exclude>packaging/*/scripts/windows/**</exclude><exclude>packaging/*/scripts/init/**</exclude><exclude>**/*.log</exclude><exclude>**/*.current</exclude><exclude>.instance_id</exclude><exclude>src/main/scripts/control/**</exclude><exclude>src/main/scripts/windows/**</exclude><exclude>src/main/resources/public/static/rulenode/**</exclude><exclude>**/*.proto.js</exclude><exclude>docker/haproxy/**</exclude><exclude>docker/tb-node/**</exclude><exclude>ui/**</exclude><exclude>src/browserslist</exclude><exclude>**/*.raw</exclude></excludes><mapping><proto>JAVADOC_STYLE</proto><cql>DOUBLEDASHES_STYLE</cql><scss>JAVADOC_STYLE</scss><jsx>SLASHSTAR_STYLE</jsx><tsx>SLASHSTAR_STYLE</tsx><conf>SCRIPT_STYLE</conf><gradle>JAVADOC_STYLE</gradle></mapping></configuration><executions><execution><goals><goal>check</goal></goals></execution></executions></plugin>
-->
  1. 修改ui-ngx工程的pom.xml文件中node的版本。
    install-node-and-npm 改为当前机器安装的版本。感觉作用不大,但是我改了。

3、 ngx-flowchart调整

因为ngx-flowchart是直接从GitHub上下载下来的,虽然编译能成功,但是会发现规则链画面打开出错。会有类似的错误提示TypeError: Class constructor X cannot be invoked without ‘new’。

修改ui-ngx的tsconfig.json,重新编译。虽然显示规则链没有问题,但是编辑规则链还是会提示错误。

"target": "es5",  ===> "target": "es6",

对应方式是把ngx-flowchart的源码放到ui-ngx中,target还是原来es5,原来依赖的地方修改一下,编译后就正常了。

  1. 把public-api.ts改名为index.ts.
  2. 搜索’ngx-flowchart/dist,分别修改。

4、编译项目

  1. 为了编译顺利,请使用管理员运行命令,如果遇到问题,请多试几次。
    mvn clean install -DskipTests
    遇到问题,可以使用命令清楚,继续运行
    mvn clear
  2. java编译问题不大,关键是在ui-ngx出错。
    主要解决方法时,在cmd进入thingsboard\ui-ngx目录,直接运行npm install 安装需要的依赖包。
    安装过程中如有问题,基本时npm的问题。可以参考此文
    本人解决主要是删除C:\Users{用户名}\AppData\Roaming下的npm。
  3. 编译成功会显示如下,此过程时间较长,12分钟左右。
[INFO] Reactor Summary for Thingsboard 3.1.0:
[INFO]
[INFO] Thingsboard ........................................ SUCCESS [  0.218 s]
[INFO] Netty MQTT Client .................................. SUCCESS [  1.937 s]
[INFO] Thingsboard Server Commons ......................... SUCCESS [  0.018 s]
[INFO] Thingsboard Server Common Data ..................... SUCCESS [  4.386 s]
[INFO] Thingsboard Server Common Utils .................... SUCCESS [  0.413 s]
[INFO] Thingsboard Server Common Messages ................. SUCCESS [  4.779 s]
[INFO] Thingsboard Actor system ........................... SUCCESS [  0.840 s]
[INFO] Thingsboard Server Stats ........................... SUCCESS [  0.457 s]
[INFO] Thingsboard Server Queue components ................ SUCCESS [  8.414 s]
[INFO] Thingsboard Server Commons ......................... SUCCESS [  0.015 s]
[INFO] Thingsboard Server Common Transport components ..... SUCCESS [  1.352 s]
[INFO] Thingsboard MQTT Transport Common .................. SUCCESS [  1.754 s]
[INFO] Thingsboard HTTP Transport Common .................. SUCCESS [  0.652 s]
[INFO] Thingsboard CoAP Transport Common .................. SUCCESS [  0.815 s]
[INFO] Thingsboard Server Common DAO API .................. SUCCESS [  1.738 s]
[INFO] Thingsboard Extensions ............................. SUCCESS [  0.014 s]
[INFO] Thingsboard Rule Engine API ........................ SUCCESS [  1.316 s]
[INFO] Thingsboard Server DAO Layer ....................... SUCCESS [ 10.084 s]
[INFO] Thingsboard Rule Engine Components ................. SUCCESS [  5.901 s]
[INFO] Thingsboard Server Transport Modules ............... SUCCESS [  0.013 s]
[INFO] Thingsboard HTTP Transport Service ................. SUCCESS [ 16.158 s]
[INFO] Thingsboard MQTT Transport Service ................. SUCCESS [ 14.366 s]
[INFO] Thingsboard CoAP Transport Service ................. SUCCESS [ 14.163 s]
[INFO] ThingsBoard Server UI .............................. SUCCESS [02:11 min]
[INFO] Thingsboard Server Tools ........................... SUCCESS [  1.115 s]
[INFO] Thingsboard Rest Client ............................ SUCCESS [  0.729 s]
[INFO] ThingsBoard Server Application ..................... SUCCESS [ 45.870 s]
[INFO] ThingsBoard Microservices .......................... SUCCESS [  0.014 s]
[INFO] ThingsBoard Docker Images .......................... SUCCESS [ 12.170 s]
[INFO] ThingsBoard JavaScript Executor Microservice ....... SUCCESS [ 59.237 s]
[INFO] ThingsBoard Web UI Microservice .................... SUCCESS [06:34 min]
[INFO] ThingsBoard Node Microservice ...................... SUCCESS [  0.140 s]
[INFO] ThingsBoard Transport Microservices ................ SUCCESS [  0.020 s]
[INFO] ThingsBoard MQTT Transport Microservice ............ SUCCESS [  2.860 s]
[INFO] ThingsBoard HTTP Transport Microservice ............ SUCCESS [  0.934 s]
[INFO] ThingsBoard COAP Transport Microservice ............ SUCCESS [  1.596 s]
[INFO] ThingsBoard Black Box Tests ........................ SUCCESS [  5.667 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12:26 min
[INFO] Finished at: 2020-09-02T15:15:56+08:00
[INFO] ------------------------------------------------------------------------

5、idea调试

  1. 使用IDEA导入Thingsboard项目,并在导入到项目后,使用菜单将Maven依赖重新引入。

    导入后,application、common,dao,netty-mqtt等各工程的sourceRoot,resourceRoot都变得正常了。

  2. 直接使用idea的debug启动ThingsboardServerApplication即可。
    注意:修改ui-ngx代码后需要执行一下编译(在ui-gnx目录下执行mvn clean install -DskipTests),直接启动才能体现。

  3. 常见错误:

  • 内存不足,配置VM Options为-Xms256m -Xmx2048m 。
  • 端口占用:默认使用的是8080,修改thingsboard.yml中配置即可。
  • DB未启动:需要安装并启动postgres,具体要求可参考
  • 中文语言包:下载的版本中,中文语言包不全,导致很多地方不能正确显示。对比ui-ngx\src\assets\locale\locale.constant-en_US.json修改ui-ngx\src\assets\locale\locale.constant-zh_CN.json即可。
  • 编译的spring-boot.jar是用解压软件打不开。如果需要编译为能打开的,修改thingsboard跟目录下的pom.xml,找到spring-boot-maven-plugin把executable改为false即可。
<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><skip>${pkg.disabled}</skip><mainClass>${pkg.mainClass}</mainClass><classifier>boot</classifier><layout>ZIP</layout><executable>false</executable><excludeDevtools>true</excludeDevtools><embeddedLaunchScriptProperties><confFolder>${pkg.installFolder}/conf</confFolder><logFolder>${pkg.unixLogFolder}</logFolder><logFilename>${pkg.name}.out</logFilename><initInfoProvides>${pkg.name}</initInfoProvides></embeddedLaunchScriptProperties></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions>
</plugin>

Thingsboard 3.1.0 - 源码编译相关推荐

  1. ThingsBoard 3.3.1源码编译-windows版

    ThingsBoard 3.3.1源码编译-windows版 前期环境准备 环境版本尽量保持一致: 建议先把文章看完再操作,不要直接看一步操作一步! 编译过程要有耐心!不要看到执行到哪一步很久不动了, ...

  2. cmake 编译curl源码_OpenCV4.0 源码编译

    之前写过几篇关于OpenCV的博客,都是基于openCV 3.14写的,10月份OpenCV发布了4.0的bate版本,我就切换到4.0版本上来.之后的博客都会是基于4.0版本的.本文主要介绍一下三个 ...

  3. ambari 2.5.0源码编译安装

    参考:https://www.ibm.com/developerworks/cn/opensource/os-cn-bigdata-ambari/index.html Ambari 是什么 Ambar ...

  4. Android4.0源码编译方法以及错误解决方案

    from:http://blog.csdn.net/wanjun8659/article/details/8095664 历时一个星期,终于将android4.0源码编译成功,中间经历了各种曲折,非常 ...

  5. postgresql 12.0 源码编译安装

    postgresql 12.0 源码编译安装 1.安装相关软件包 su - root yum install -y cmake gcc gcc-c++ perl readline readline-d ...

  6. Atlas 2.2.0源码编译及安装步骤

    Atlas 2.2.0源码编译及安装步骤 一.源码编译 1. 下载源码 2. 前置环境安装 3. 修改版本号 4. 修改源码中 atlas与kafka版本兼容问题 5. 开始编译 6. 问题锦集 二. ...

  7. tesseract-4.0.0源码编译安装

    tesseract-4.0.0源码编译安装 安装开发工具 apt-get -y install gcc g++ make cmake autoconf automake libtool pkg-con ...

  8. python 3.10.0源码编译安装

    python 3.10.0源码编译安装 文章目录 python 3.10.0源码编译安装 1. 安装编译依赖工具 2. 下载python 3.10.0 3. 编译安装 Python 4. 体验 1. ...

  9. ThingsBoard——v3.3.3源码编译

    要二次开发,肯定少不了编译源码.编译的难点就是坑多,因为我们的环境不可能跟源码作者的一样,当然你的跟我的也可能不一样.我的环境:系统:macOS10.15.5,CPU i7 1 准备工作 1.1 编译 ...

  10. linux gcc-9.2.0 源码编译

    目录 下载gcc-9.2.0源码 解压源码包 下载依赖 创建编译输出目录 编译配置信息 编译 安装 清理 查看GLIBCXX的版本 验证 下载gcc-9.2.0源码 http://ftp.gnu.or ...

最新文章

  1. 乾坤合一~Linux设备驱动之终端设备驱动
  2. pycharm中设置pytest方式(Mac)
  3. Mangos源码分析(2):服务器结构探讨之登录服的负载均衡
  4. maven docker 插件集成的几个小坑
  5. QCon2016 上海会议汇总(1) - 前端技术实践
  6. 第二阶段团队冲刺02
  7. 【Vegas原创】windows2008配置、安装Exchange2007证书(for OWA,RPC over HTTP)
  8. 使得电脑成为通用计算机器,为什么电脑显示器变成通用非即插即用监视器?
  9. html5教学案例撰写,教学案例撰写基本格式
  10. ps4html5播放器,PS4终获得全新媒体播放器 允许从PC或U盘串流媒体
  11. xlsx文件怎么打开
  12. 成都中忻嘉业:抖音小店经营一段时间后能改类目吗
  13. 解决VirtualBox配置静态ip和连外网的问题
  14. 计算机专业毕业设计选题推荐(建议收藏)
  15. C语言第二课:项目的创建、基本结构与两个常见问题的处理
  16. db2系统表相应功能
  17. 长时间戴耳机选哪一种、目前最好用的骨传导耳机品推荐
  18. 嵌入式C/C++面试题
  19. 打印订单--bcty365
  20. 全面战争:三国 破解版安装教程

热门文章

  1. [ZT]javascript window resize 窗口改变事件
  2. ASP.NET profile之 找不到存储过程'dbo.aspnet_CheckSchemaVersion'
  3. 解决在firefox浏览器不支持ajax的transport.responseXml方法问题
  4. Linux下PHP开启Oracle支持(oci8)
  5. 想成为大数据分析师必须知道的这些事儿(文末福利)
  6. 《C++代码设计与重用》——2.7 转型
  7. 上传伪技术~很多人都以为判断了后缀,判断了ContentType,判断了头文件就真的安全了。是吗?...
  8. 打造高效的运维日志收集与分析平台
  9. css3学习总结9--CSS3过渡
  10. 配置Web.Config连接数据库