落烨无痕

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

因为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>

posted on 2018-05-17 16:16  落烨无痕  阅读(20996)  评论(0编辑  收藏  举报