赞
踩
JDK1.8
Postgresql 11
Node.js
Yarn
Maven 3.6.3
Git
Idea
Redis
git clone https://github.com/thingsboard/thingsboard.git
下载后进到thingsboard文件夹,git checkout到指定的版本,这里切换到thingsboardv3.2.1版本,对应的是java8。
编译前先做一些准备工作,不然可能遇到各种莫名其妙的错误。
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 检查报错。
- <!-- <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/.browserslistrc</exclude>
- <exclude>**/yarn.lock</exclude>
- <exclude>**/*.raw</exclude>
- <exclude>**/apache/cassandra/io/**</exclude>
- <exclude>.run/**</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> -->
3.修改maven安装目录下conf里的settings.xml配置文件,将镜像修改为以下内容:
- <mirror>
- <id>central</id>
- <name>aliyun central</name>
- <url>https://maven.aliyun.com/repository/central</url>
- <mirrorOf>central</mirrorOf>
- </mirror>
- <mirror>
- <id>google</id>
- <name>aliyun google</name>
- <url>https://maven.aliyun.com/repository/google</url>
- <mirrorOf>google</mirrorOf>
- </mirror>
- <mirror>
- <id>public</id>
- <name>aliyun public</name>
- <url>https://maven.aliyun.com/repository/public</url>
- <mirrorOf>public</mirrorOf>
- </mirror>
- <mirror>
- <id>gradle-plugin</id>
- <name>aliyun gradle-plugin</name>
- <url>https://maven.aliyun.com/repository/gradle-plugin</url>
- <mirrorOf>gradle-plugin</mirrorOf>
- </mirror>
- <mirror>
- <id>spring</id>
- <name>aliyun spring</name>
- <url>https://maven.aliyun.com/repository/spring</url>
- <mirrorOf>spring</mirrorOf>
- </mirror>
- <mirror>
- <id>spring-plugin</id>
- <name>aliyun spring-plugin</name>
- <url>https://maven.aliyun.com/repository/spring-plugin</url>
- <mirrorOf>spring-plugin</mirrorOf>
- </mirror>
- <mirror>
- <id>grails-core</id>
- <name>aliyun grails-core</name>
- <url>https://maven.aliyun.com/repository/grails-core</url>
- <mirrorOf>grails-core</mirrorOf>
- </mirror>
- <mirror>
- <id>apache-snapshots</id>
- <name>aliyun apache-snapshots</name>
- <url>https://maven.aliyun.com/repository/apache-snapshots</url>
- <mirrorOf>apache-snapshots</mirrorOf>
- </mirror>
- <!-- 中央仓库1 -->
- <mirror>
- <id>repo1</id>
- <mirrorOf>central</mirrorOf>
- <name>Human Readable Name for this Mirror.</name>
- <url>http://insecure.repo1.maven.org/maven2/</url>
- </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
编译成功后,配置好数据库,就可以成功运行啦。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。