快速开始
约 550 字大约 2 分钟
快速开始
此处将展示一个 最少配置 的 808协议 消息处理服务的搭建。
传送门
本小节的示例可以在 samples/jt-808-server-sample-bare 下找到对应代码。
创建工程
创建一个空的 spring-boot 工程。
传送门
可以使用 Spring Initializer 快速初始化一个 Spring Boot 工程。
添加依赖
spring-boot-2.x
使用 spring-boot-2.x 的项目引入为 808协议 提供的 jt-808-server-spring-boot-starter-boot2
maven
<dependency>
    <groupId>io.github.hylexus.jt</groupId>
    <artifactId>jt-808-server-spring-boot-starter-boot2</artifactId>
    <version>2.3.0-rc.6</version>
</dependency>
gradle
implementation 'io.github.hylexus.jt:jt-808-server-spring-boot-starter-boot2:2.3.0-rc.6'
spring-boot-3.x
使用 spring-boot-3.x 的项目引入为 808协议 提供的 jt-808-server-spring-boot-starter
maven
<dependency>
    <groupId>io.github.hylexus.jt</groupId>
    <artifactId>jt-808-server-spring-boot-starter</artifactId>
    <version>2.3.0-rc.6</version>
</dependency>
gradle
implementation 'io.github.hylexus.jt:jt-808-server-spring-boot-starter:2.3.0-rc.6'
配置
- application.yml
 
jt808:
  built-components:
    component-statistics:
      enabled: true
    request-handlers:
      enabled: true
logging:
  level.root: info
  level.io.github.hylexus: info
  level.jt-808.request.decoder: debug
  level.jt-808.response.encoder: debug
测试
启动项目
至此,对 808消息 的处理服务已经搭建完毕。启动 spring-boot 项目开始测试。

可以从启动日志中的组件统计信息中看到内置了一些消息处理器:
0x0100终端注册0x0102终端鉴权0x0200定位数据上报0x0704定位数据批量上报
所以现在可以测试接收内置的这些类型的消息了。下面以 2019 版的 终端注册消息 为例进行测试:
配置提示
组件统计信息的开关由配置项jt808.print-component-statistics = true|false来控制- 默认的 
TCP端口为6808 
发报文
- 报文
 
[7E010040560100000000013912344321007B000B0000313233353931323335393131323334353637383930313233343536373839303132333435363738393069643132333435363738393031323334353637383930313233343536373801B8CA4A2D3635343332313C7E]
- 客户端
 

服务端

传送门
本小节的示例可以在 samples/jt-808-server-sample-bare 下找到对应代码。
