【智慧物联网平台】安装部署教程——仙盟创梦IDE

发布于:2025-07-29 ⋅ 阅读:(19) ⋅ 点赞:(0)

一、部署前准备

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=utf8
        username: 数据库用户名
        password: 数据库密码
    

2. 配置 Redis

  • 在服务配置文件中添加 Redis 连接信息(用于缓存和会话管理):

    yaml

    spring:
      redis:
        host: localhost
        port: 6379
        password: 你的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-eurekaiot-gateway 等),需按依赖顺序启动:先启动注册中心(iot-eureka),再启动网关(iot-gateway),最后启动业务服务(如 iot-accessControliot-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 路由
        }
      }
      

四、服务配置与验证

1. 关键配置调整

  • 接口地址:前端需配置后端接口地址(如 iot-gateway 网关地址),确保与后端服务通信。
  • 设备对接
    • 门禁、道闸等设备需在系统中添加设备信息(IP 地址、端口、协议等),参考仓库中 iot-accessControliot-barrier 模块的说明。
    • 充电桩、智能表等设备需通过接口或协议(如 MQTT)与系统对接,具体可查看 iot-chargeiot-meter 模块的代码注释。

2. 验证部署结果

  • 访问管理端:通过 Nginx 配置的域名或服务器 IP + 端口访问前端页面(如 http://localhost:80),使用默认账号登录:
    • 运营账号:admin/admin
    • 物业账号:18909715555/123456
  • 检查服务状态:访问后端接口文档(默认路径 http://localhost:9999/doc-ui.html),验证接口是否正常响应。

五、其他注意事项

  1. 依赖服务

    • 确保 MySQL、Redis 服务正常运行,且网络通畅(防火墙需开放相关端口,如 3306、6379、8761 等)。
    • 若使用 Eureka 注册中心,需保证各服务能正常注册(默认地址 http://localhost:8761)。
  2. 日志与调试

    • 服务启动日志可通过 java -jar 命令的控制台输出查看,或配置日志文件路径(参考 logback.xml 配置)。
    • 若启动失败,检查端口冲突(如 netstat -tulpn | grep 9999)或数据库连接是否正确。
  3. 文档参考

    • 仓库中的 readme.mdCHNAGE_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.


网站公告

今日签到

点亮在社区的每一天
去签到