thingsboard填坑之路

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

thingsboard官網源碼安裝鏈接:node

 
個人安裝環境: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>git

須要改爲對應本地的版本號。github

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

 

問題二npm

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

[ERROR] npm ERR! code ENOGITapp

[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:frontend

 

[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]eclipse

 

緣由:iphone

沒有安裝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>

相關文章
相關標籤/搜索