跳到主要内容

Spring Boot 集成

Orbien 提供可内嵌到 Spring Boot 的 Java 客户端,当前能力:

  • 隧道协议:仅 TCPHTTP
  • 传输层:仅 TCP
  • 不支持 TCP 多路复用orbien.tcp-mux 必须为 false,服务端也需 [transport].tcpMux = false(服务端默认开启多路复用,与 Java 客户端联调时需显式关闭)
<dependency>
<groupId>io.github.lxien</groupId>
<artifactId>orbien-spring-boot-starter</artifactId>
<version>3.6.0</version>
</dependency>

最小配置

local-port / name 可省略:未填时分别使用 Spring Boot Web 端口与 spring.application.name(或 orbien-{protocol})。

# application.yml
orbien:
enabled: true
server: "127.0.0.1:9527"
# token: YOUR_TOKEN # 可选
tunnel:
protocol: http
domains:
- web.domain.com

服务端需关闭多路复用,例如:

# orbien-server.toml
listen = "0.0.0.0:9527"
httpGwPort = 80

[transport]
tcpMux = false # 关闭 TCP 多路复用

完整参考

# application.yml
orbien:
enabled: true
server: "127.0.0.1:9527"
token: YOUR_TOKEN
tcp-mux: false # 必须为 false,且与服务端一致
pool-count: 1 # 登录时预申请的数据连接池大小
heartbeat-interval-secs: 30
user: spring-boot-demo # 可选,展示在 Dashboard
# session-id: "" # 可选;为空则从 session-id-file 恢复,或自动生成
# session-id-file: "" # 可选;为空则使用用户目录下的默认路径
tunnel:
name: web-demo # 可选
protocol: http # tcp | http
local-ip: 127.0.0.1
# local-port: 8080 # 可选;未填则使用 Spring Boot 监听端口
# remote-port: 9000 # 仅 protocol=tcp 时需要
domains: # protocol=http 时必填
- web.domain.com