一、部署前準備
1. 環境要求
- 基礎環境:JDK 1.8+、MySQL 5.7+/8.0、Maven 3.6+、Redis(用于緩存)、Node.js(用于前端構建,可選)。
- 依賴服務:若需對接門禁、道閘等硬件設備,需確保設備網絡可達(如通過局域網或網關接入)。
2. 源碼獲取
- 從 Gitee 倉庫克隆源碼:
bash
git clone https://gitee.com/java110/MicroCommunityIot.git cd MicroCommunityIot
二、后端部署(Spring Boot 服務)
1. 配置數據庫
- 導入數據庫腳本:倉庫中?
java110-db
?模塊包含數據庫腳本,將其導入 MySQL 中:bash
# 假設腳本路徑為 java110-db/src/main/resources/sql/ mysql -u 用戶名 -p 數據庫名 < java110-db/src/main/resources/sql/init.sql
- 修改數據庫配置:在?
java110-boot
?或各微服務模塊的?application.yml
?中配置數據庫連接:yaml
spring:datasource:url: jdbc:mysql://localhost:3306/hc_iot?useUnicode=true&characterEncoding=utf8username: 數據庫用戶名password: 數據庫密碼
2. 配置 Redis
- 在服務配置文件中添加 Redis 連接信息(用于緩存和會話管理):
yaml
spring:redis:host: localhostport: 6379password: 你的Redis密碼(若有)
3. 編譯打包
- 使用 Maven 編譯整個項目(支持多模塊打包):
bash
mvn clean package -Dmaven.test.skip=true
- 打包后,可執行 Jar 包位于各模塊的?
target
?目錄下(如?java110-boot/target/java110-boot.jar
)。
4. 啟動服務
- 直接運行 Jar 包(以?
java110-boot
?為例,其他服務類似):bash
java -jar java110-boot/target/java110-boot.jar --spring.profiles.active=dev # 指定環境(dev/test/prod)
- 若為微服務架構(含?
iot-eureka
、iot-gateway
?等),需按依賴順序啟動:先啟動注冊中心(iot-eureka
),再啟動網關(iot-gateway
),最后啟動業務服務(如?iot-accessControl
、iot-barrier
?等)。
三、前端部署(Vue/uni-app)
1. 編譯前端項目
- 倉庫中?
iot-h5
(H5 界面)、iot-web
(管理端)等模塊為前端代碼,需先安裝依賴并打包:bash
# 進入前端模塊目錄 cd iot-web npm install # 安裝依賴 npm run build # 打包生成 dist 目錄
2. 部署靜態資源
- 將打包后的?
dist
?目錄部署到 Nginx 或 Apache 服務器:- 配置 Nginx 示例:
nginx
server {listen 80;server_name iot.example.com; # 你的域名root /path/to/iot-web/dist; # 前端打包目錄index index.html;location / {try_files $uri $uri/ /index.html; # 支持 Vue 路由} }
- 配置 Nginx 示例:
四、服務配置與驗證
1. 關鍵配置調整
- 接口地址:前端需配置后端接口地址(如?
iot-gateway
?網關地址),確保與后端服務通信。 - 設備對接:
- 門禁、道閘等設備需在系統中添加設備信息(IP 地址、端口、協議等),參考倉庫中?
iot-accessControl
、iot-barrier
?模塊的說明。 - 充電樁、智能表等設備需通過接口或協議(如 MQTT)與系統對接,具體可查看?
iot-charge
、iot-meter
?模塊的代碼注釋。
- 門禁、道閘等設備需在系統中添加設備信息(IP 地址、端口、協議等),參考倉庫中?
2. 驗證部署結果
- 訪問管理端:通過 Nginx 配置的域名或服務器 IP + 端口訪問前端頁面(如?
http://localhost:80
),使用默認賬號登錄:- 運營賬號:
admin/admin
- 物業賬號:
18909715555/123456
- 運營賬號:
- 檢查服務狀態:訪問后端接口文檔(默認路徑?
http://localhost:9999/doc-ui.html
),驗證接口是否正常響應。
五、其他注意事項
依賴服務:
- 確保 MySQL、Redis 服務正常運行,且網絡通暢(防火墻需開放相關端口,如 3306、6379、8761 等)。
- 若使用 Eureka 注冊中心,需保證各服務能正常注冊(默認地址?
http://localhost:8761
)。
日志與調試:
- 服務啟動日志可通過?
java -jar
?命令的控制臺輸出查看,或配置日志文件路徑(參考?logback.xml
?配置)。 - 若啟動失敗,檢查端口沖突(如?
netstat -tulpn | grep 9999
)或數據庫連接是否正確。
- 服務啟動日志可通過?
文檔參考:
- 倉庫中的?
readme.md
、CHNAGE_LOG.md
?及?java110-doc
?模塊可能包含更詳細的部署步驟和接口說明,建議結合查閱。
- 倉庫中的?
?
阿雪技術觀
在科技發展浪潮中,我們不妨積極投身技術共享。不滿足于做受益者,更要主動擔當貢獻者。無論是分享代碼、撰寫技術博客,還是參與開源項目維護改進,每一個微小舉動都可能蘊含推動技術進步的巨大能量。東方仙盟是匯聚力量的天地,我們攜手在此探索硅基生命,為科技進步添磚加瓦。
Hey folks, in this wild tech - driven world, why not dive headfirst into the whole tech - sharing scene? Don't just be the one reaping all the benefits; step up and be a contributor too. Whether you're tossing out your code snippets, hammering out some tech blogs, or getting your hands dirty with maintaining and sprucing up open - source projects, every little thing you do might just end up being a massive force that pushes tech forward. And guess what? The Eastern FairyAlliance is this awesome place where we all come together. We're gonna team up and explore the whole silicon - based life thing, and in the process, we'll be fueling the growth of technology.