thingsboard填坑之路


因為thingsboard都是國外的資料,國內基本沒有參考資料。所以,記錄下來源碼安裝當中,遇到的問題。

thingsboard官網源碼安裝連接:

 
我的安裝環境:win7,已有軟件:node,eclipse,maven
 
問題一
根據官方的安裝步驟,執行到
mvn clean install -DskipTests 
這一步的時候,報一下錯誤:
 
Failed to run task: 'npm install' failed. java.io.IOException: Cannot run program "E:\git\thingsboard\ui\target\node\node.exe" (indirectory "E:\git\thingsboard\ui"): CreateProcess error=193, %1 不是有效的 Win32 應用程序。 -> [Help 1]
 
原因:
在UI在的pom.xml文件中,默認指定了安裝node的版本號。如果之前沒有安裝過node的話,應該不會報這個錯誤的。因為我之前安裝過的,所以需要修改pom.xml
里面的node版本號:

<nodeVersion>v6.9.1</nodeVersion>
<npmVersion>3.10.8</npmVersion>

需要改成對應本地的版本號。

如果還是報錯,將已經安裝的D:\Program Files\nodejs\node.exe(node的安裝路徑)復制到maven對應的目錄下D:\m2\com\github\eirslett\node\10.1.0(maven下的node目錄,版本號自行對應)

 

問題二

根據官方的安裝步驟,執行到
mvn clean install -DskipTests 
這一步的時候,報一下錯誤:

[ERROR] npm ERR! code ENOGIT

[ERROR] npm ERR! No git binary found in $PATH
[ERROR] npm ERR!
[ERROR] npm ERR! Failed using git.
[ERROR] npm ERR! Please check if you have git installed and in your PATH.
[ERROR]
[ERROR] npm ERR! A complete log of this run can be found in:

 

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0:npm
(npm install) on project ui: Failed to run task: 'npm install' failed. (error c
ode 1) -> [Help 1]

 

原因:

沒有安裝git或者是沒有配置git的環境變量

 

問題三

[ERROR] Failed to execute goal com.mycila:license-maven-plugin:3.0:check (default) on project xxx: Some files do not have the expected license header -> [Help 1] 

 

原因:

因為maven會對license進行檢車check,而配置文件缺少頭部license聲明,所以報錯,無法執行下去。

mvn clean install -DskipTests license:format
增加  license:format 參數
 
如果還是報錯,則需要屏蔽根目錄下的pom.xml文件代碼段:

<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>

 
 
打包成功效果圖:
 
問題四
build完成后,導入到eclipse。報錯找不到相關的類或者方法,譬如:
The import org.thingsboard.server.extensions.core.plugin.telemetry.gen cannot be resolved
AttributeUpdateProto cannot be resolved to a type
 
原因:

修改根目錄下的pom.xml的內容:                 

<configuration>
<sources>
<!-- <source>${basedir}/target/generated-sources</source> -->
<source>${basedir}/target/generated-sources/grpc-java</source>
<source>${basedir}/target/generated-sources/java</source>
</sources>
</configuration>

 
protobuf相關的代碼文件沒有生成。
使用protobuf生成對應的文檔。只需要用protobuf.exe在eclipse之外生成對應的java文件“org.thingsboard.server.extensions.core.plugin.telemetry.gen”即可
在extensions-core的target/generated-sources中,也能找到生成的文件,直接拷貝到src對應的目錄亦可。 同時,需要把application項目和extensions-core項目中的路徑target/generated-sources刪除
 
protobuf插件安裝教程:
https://blog.csdn.net/iphone4grf/article/details/50902816
 
protobuf對應的grpc工具下載地址:
https://blog.csdn.net/y515789/article/details/54378325
 
 
問題五
中文大概意思:導入到eclipse中,就一堆報錯信息

I got successful maven build.

However, this is lots of code errors in the code base. The errors are categories to four types.

  1. Eclipse complains log object does not define.
    e.g. log.info("[{}:{}] MQTT broker connection established!", configuration.getHost(), configuration.getPort());

  2. Eclipse complains final variables not initialized. "The blank final field nodeId may not have been initialized"

  3. Object function setter & getter function undefines. I saw properties but there is not explicitly setter and getter for those properties.

4 Object not constructor. I saw some objects only has properties (some of them define as final), However, this is not constructors for those objects.

原因:

安裝lombok插件

方案:https://github.com/thingsboard/thingsboard-gateway/issues/36

Lombok plugin for Eclipse

安裝lombok方法:https://blog.csdn.net/dorothy1224/article/details/79280591/

 

問題六

src.main都作為了路徑,無法形成maven項目

 

 方法:

屏蔽pom.xml文件中的protobuf插件。涉及到的項目有application,extensions-core。屏蔽后,需要在maven選項中update project

 

 

問題七

extension-sns,extension-sqs報錯:

The type org.apache.velocity.Template cannot be resolved

 

方法:

在這兩個項目中添加依賴

<dependency>
  <groupId>org.apache.velocity</groupId>
  <artifactId>velocity</artifactId>
</dependency>

 

問題八

application報錯:

ClusterAPIProtos cannot be resolved ClusterGrpcService.java

 

方法:

將application\target\generated-sources\protobuf\grpc-java\org\thingsboard\server\gen,

application\target\generated-sources\protobuf\java\org\thingsboard\server\gen,

extensions-core\target\generated-sources\protobuf\java\org\thingsboard\server\plugin\telmetry\gen生成的

代碼(包括目錄)復制到src中

 

問題九

忘記是什么問題了,但是需要在maven的setting.xml文件中加配置信息:

<activeProfiles>
  <activeProfile>env-thing</activeProfile>
</activeProfiles>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM