当前位置:   article > 正文

物联网平台Thingsboard3.2.1源码编译记录

物联网平台Thingsboard3.2.1源码编译记录

1.开发环境

JDK1.8

Postgresql 11

Node.js

Yarn 

Maven 3.6.3

Git

Idea

Redis

 2.克隆源码

git clone https://github.com/thingsboard/thingsboard.git

下载后进到thingsboard文件夹,git checkout到指定的版本,这里切换到thingsboardv3.2.1版本,对应的是java8。

3.编译安装

编译前先做一些准备工作,不然可能遇到各种莫名其妙的错误。

1.node和yarn版本与源码pom.xml中的版本号对应上,避免有些包下载不下来报错,可以下载nvm工具,方便切换不同的node版本,thingsboard3.2.1对应的版本号如下:

<configuration>

<nodeVersion>v12.16.1</nodeVersion>

<yarnVersion>v1.22.4</yarnVersion>

</configuration>

如果不想更换nodejs版本,在ui-ngx\pom.xml,msa模块下 js-executor、web-ui子模块中的pom.xml三处将node修改为本地版本,3.2.1对应的nodejs版本在12~14之间,node版本高了编译会报错。

2.在根目录的pom文件中找到license-maven-plugin,将整个plugin内容注释掉,以免后续License 检查报错。

  1. <!-- <plugin>
  2. <groupId>com.mycila</groupId>
  3. <artifactId>license-maven-plugin</artifactId>
  4. <version>3.0</version>
  5. <configuration>
  6. <header>${main.dir}/license-header-template.txt</header>
  7. <properties>
  8. <owner>The Thingsboard Authors</owner>
  9. </properties>
  10. <excludes>
  11. <exclude>**/.env</exclude>
  12. <exclude>**/*.env</exclude>
  13. <exclude>**/.eslintrc</exclude>
  14. <exclude>**/.babelrc</exclude>
  15. <exclude>**/.jshintrc</exclude>
  16. <exclude>**/.gradle/**</exclude>
  17. <exclude>**/nightwatch</exclude>
  18. <exclude>**/README</exclude>
  19. <exclude>**/LICENSE</exclude>
  20. <exclude>**/banner.txt</exclude>
  21. <exclude>node_modules/**</exclude>
  22. <exclude>**/*.properties</exclude>
  23. <exclude>src/test/resources/**</exclude>
  24. <exclude>src/vendor/**</exclude>
  25. <exclude>src/font/**</exclude>
  26. <exclude>src/sh/**</exclude>
  27. <exclude>packaging/*/scripts/control/**</exclude>
  28. <exclude>packaging/*/scripts/windows/**</exclude>
  29. <exclude>packaging/*/scripts/init/**</exclude>
  30. <exclude>**/*.log</exclude>
  31. <exclude>**/*.current</exclude>
  32. <exclude>.instance_id</exclude>
  33. <exclude>src/main/scripts/control/**</exclude>
  34. <exclude>src/main/scripts/windows/**</exclude>
  35. <exclude>src/main/resources/public/static/rulenode/**</exclude>
  36. <exclude>**/*.proto.js</exclude>
  37. <exclude>docker/haproxy/**</exclude>
  38. <exclude>docker/tb-node/**</exclude>
  39. <exclude>ui/**</exclude>
  40. <exclude>src/.browserslistrc</exclude>
  41. <exclude>**/yarn.lock</exclude>
  42. <exclude>**/*.raw</exclude>
  43. <exclude>**/apache/cassandra/io/**</exclude>
  44. <exclude>.run/**</exclude>
  45. </excludes>
  46. <mapping>
  47. <proto>JAVADOC_STYLE</proto>
  48. <cql>DOUBLEDASHES_STYLE</cql>
  49. <scss>JAVADOC_STYLE</scss>
  50. <jsx>SLASHSTAR_STYLE</jsx>
  51. <tsx>SLASHSTAR_STYLE</tsx>
  52. <conf>SCRIPT_STYLE</conf>
  53. <gradle>JAVADOC_STYLE</gradle>
  54. </mapping>
  55. </configuration>
  56. <executions>
  57. <execution>
  58. <goals>
  59. <goal>check</goal>
  60. </goals>
  61. </execution>
  62. </executions>
  63. </plugin> -->

3.修改maven安装目录下conf里的settings.xml配置文件,将镜像修改为以下内容:

  1. <mirror>
  2. <id>central</id>
  3. <name>aliyun central</name>
  4. <url>https://maven.aliyun.com/repository/central</url>
  5. <mirrorOf>central</mirrorOf>
  6. </mirror>
  7. <mirror>
  8. <id>google</id>
  9. <name>aliyun google</name>
  10. <url>https://maven.aliyun.com/repository/google</url>
  11. <mirrorOf>google</mirrorOf>
  12. </mirror>
  13. <mirror>
  14. <id>public</id>
  15. <name>aliyun public</name>
  16. <url>https://maven.aliyun.com/repository/public</url>
  17. <mirrorOf>public</mirrorOf>
  18. </mirror>
  19. <mirror>
  20. <id>gradle-plugin</id>
  21. <name>aliyun gradle-plugin</name>
  22. <url>https://maven.aliyun.com/repository/gradle-plugin</url>
  23. <mirrorOf>gradle-plugin</mirrorOf>
  24. </mirror>
  25. <mirror>
  26. <id>spring</id>
  27. <name>aliyun spring</name>
  28. <url>https://maven.aliyun.com/repository/spring</url>
  29. <mirrorOf>spring</mirrorOf>
  30. </mirror>
  31. <mirror>
  32. <id>spring-plugin</id>
  33. <name>aliyun spring-plugin</name>
  34. <url>https://maven.aliyun.com/repository/spring-plugin</url>
  35. <mirrorOf>spring-plugin</mirrorOf>
  36. </mirror>
  37. <mirror>
  38. <id>grails-core</id>
  39. <name>aliyun grails-core</name>
  40. <url>https://maven.aliyun.com/repository/grails-core</url>
  41. <mirrorOf>grails-core</mirrorOf>
  42. </mirror>
  43. <mirror>
  44. <id>apache-snapshots</id>
  45. <name>aliyun apache-snapshots</name>
  46. <url>https://maven.aliyun.com/repository/apache-snapshots</url>
  47. <mirrorOf>apache-snapshots</mirrorOf>
  48. </mirror>
  49. <!-- 中央仓库1 -->
  50. <mirror>
  51. <id>repo1</id>
  52. <mirrorOf>central</mirrorOf>
  53. <name>Human Readable Name for this Mirror.</name>
  54. <url>http://insecure.repo1.maven.org/maven2/</url>
  55. </mirror>

4.在C盘用户目录下,.pkg-cach.v2.6里添加对应的文件

 github下载地址:Release v2.6 · vercel/pkg-fetch · GitHub

下载linux和win版本两个文件到本地,下载后重命名为fetched-v12.16.1-win-x64;fetched-v12.16.1-linux-x64,保证和本地nodejs版本一致,如下图:

5.进入thingsboard 文件夹,执行下面的编译命令

mvn clean install -DskipTests 

 编译时间比较长,遇到网络问题下载失败,可以连接外网或者手机热点,编译成功信息如下:

 [INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Thingsboard 3.2.1:
[INFO]
[INFO] Thingsboard ........................................ SUCCESS [  0.240 s]
[INFO] Netty MQTT Client .................................. SUCCESS [  0.746 s]
[INFO] Thingsboard Server Commons ......................... SUCCESS [  0.023 s]
[INFO] Thingsboard Server Common Data ..................... SUCCESS [  0.900 s]
[INFO] Thingsboard Server Common Utils .................... SUCCESS [  0.075 s]
[INFO] Thingsboard Server Common Messages ................. SUCCESS [  1.919 s]
[INFO] Thingsboard Actor system ........................... SUCCESS [  0.086 s]
[INFO] Thingsboard Server Stats ........................... SUCCESS [  0.107 s]
[INFO] Thingsboard Server Queue components ................ SUCCESS [  6.500 s]
[INFO] Thingsboard Server Commons ......................... SUCCESS [  0.026 s]
[INFO] Thingsboard Server Common Transport components ..... SUCCESS [  1.872 s]
[INFO] Thingsboard MQTT Transport Common .................. SUCCESS [  0.260 s]
[INFO] Thingsboard HTTP Transport Common .................. SUCCESS [  0.130 s]
[INFO] Thingsboard CoAP Transport Common .................. SUCCESS [  0.120 s]
[INFO] Thingsboard Server Common DAO API .................. SUCCESS [  0.198 s]
[INFO] Thingsboard Extensions ............................. SUCCESS [  0.025 s]
[INFO] Thingsboard Rule Engine API ........................ SUCCESS [  0.153 s]
[INFO] Thingsboard Server DAO Layer ....................... SUCCESS [  0.634 s]
[INFO] Thingsboard Rule Engine Components ................. SUCCESS [  0.659 s]
[INFO] Thingsboard Server Transport Modules ............... SUCCESS [  0.023 s]
[INFO] Thingsboard HTTP Transport Service ................. SUCCESS [ 14.392 s]
[INFO] Thingsboard MQTT Transport Service ................. SUCCESS [ 12.769 s]
[INFO] Thingsboard CoAP Transport Service ................. SUCCESS [ 12.785 s]
[INFO] ThingsBoard Server UI .............................. SUCCESS [01:12 min]
[INFO] Thingsboard Server Tools ........................... SUCCESS [  0.153 s]
[INFO] Thingsboard Rest Client ............................ SUCCESS [  0.117 s]
[INFO] ThingsBoard Server Application ..................... SUCCESS [ 25.174 s]
[INFO] ThingsBoard Microservices .......................... SUCCESS [  0.019 s]
[INFO] ThingsBoard Docker Images .......................... SUCCESS [  0.684 s]
[INFO] ThingsBoard JavaScript Executor Microservice ....... SUCCESS [01:12 min]
[INFO] ThingsBoard Web UI Microservice .................... SUCCESS [ 19.659 s]
[INFO] ThingsBoard Node Microservice ...................... SUCCESS [  0.136 s]
[INFO] ThingsBoard Transport Microservices ................ SUCCESS [  0.016 s]
[INFO] ThingsBoard MQTT Transport Microservice ............ SUCCESS [  0.088 s]
[INFO] ThingsBoard HTTP Transport Microservice ............ SUCCESS [  0.092 s]
[INFO] ThingsBoard COAP Transport Microservice ............ SUCCESS [  0.086 s]
[INFO] ThingsBoard Black Box Tests ........................ SUCCESS [ 22.715 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:29 min
[INFO] Finished at: 2022-09-05T13:20:23+08:00
[INFO] ------------------------------------------------------------------------

基本的环境安装或者遇到更多编译错误可以参考下面的文章:Thingsboard入门教程:本地环境搭建和源码编译安装,献给thingsboard编译失败的同学,教程不断优化 · 物联网技术社区-物联网平台-ThingsBoard

编译成功后,配置好数据库,就可以成功运行啦。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/638600
推荐阅读
相关标签
  

闽ICP备14008679号