--- title: TB-CE Source 擴展功能 tags: ThingsBoard, Spring Boot 二次開發 --- ## 前置 1. [下載 release source code](https://github.com/thingsboard/thingsboard/releases) 2. 使用 IDE ( IntelliJ IDEA || Eclipse ) 3. 執行 ( on terminal ) ``` mvn clean install -DskipTests ``` 4. 建立 database ( 可使用 pgAdmin GUI介面 )  5. database 初始化資料建立 1. 複製 `thingsboard\dao\src\main\resources\sql` 到 `thingsboard\application\src\main\data` 2. Run `thingsboard\application\src\main\java\org\thingsboard\server\ThingsboardInstallApplication.java` ( 執行前確認 DB 相關設定 如帳號密碼,Port,DB 名稱等 ) 6. Run `thingsboard\application\src\main\java\org\thingsboard\server\ThingsboardServerApplication.java` 確認是否能正常啟動 ## 擴展 1. 建立 Spring Boot Project ( https://start.spring.io/ || 透過 IDE ) 2. 建立功能所需 MVC 並執行確認功能是否正常使用 3. Thingsboard Spring Boot Application 修改 ``` - @ComponentScan({"org.thingsboard.server"}) + @ComponentScan({"org.thingsboard.server", "com.fgiotlead.smartRV"}) ``` 4. 執行 ( on terminal ) ``` mvn clean install -DskipTests ``` 5. `thingsboard\application\pom.xml` 加入 dependency ``` <dependency> <groupId>com.fgiotlead</groupId> <artifactId>SmartRV</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> ``` 6. 執行 Spring Boot Application 並觀察 [swagger](http://localhost:8080/swagger-ui/#/) 是否有成功讀入新增的 controller ## Issues * ~~若有引入 `spring-boot-maven-plugin` 時,mvn install 預設將專案打包為可獨立執行的 jar,與依賴使用的 jar 結構不同,多了`BOOT-INF/classes`。~~ * sol: ``` <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> ``` * Eclipse 沒有內建 Protobuf,TB 有些 package ( 如 org.thingsboard.server.gen ),是透過 proto 自動建立,但目前補上插件依然有誤,待解決。 * ~~[sol](https://blog.csdn.net/iphone4grf/article/details/50902816)~~ ## References * [亿琪软件官方博客](https://www.yiqisoft.cn/blogs/) * [开源|ThingsBoard 项目实施及二次开发要点总结](https://www.yiqisoft.cn/blogs/category/thingsboard/1/)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up