温馨提示×

Debian中Swagger怎调试

小樊
42
2026-09-28 20:43:15
栏目: 智能运维

在 Debian 系统里“调试 Swagger”通常分几种场景,我先按最常见情况说明,你可对号入座。


一、你是「Spring Boot + Swagger」项目(最常见)

1. 确认 Swagger 是否真的启动

访问:

http://localhost:8080/swagger-ui.html
# 或新版本
http://localhost:8080/swagger-ui/index.html

如果打不开:

curl -i http://localhost:8080/swagger-ui.html

2. 看后端日志(最重要)

journalctl -u your-service
# 或
tail -f logs/spring.log

常见错误:

  • Failed to start bean 'documentationPluginsBootstrapper'
  • No qualifying bean of type 'org.springframework.data.rest.core.support.Entity...'

3. 常见 Swagger 调试问题(Debian 环境)

✅ Spring Boot 2.6+ 与 Swagger 不兼容

spring:
  mvc:
    pathmatch:
      matching-strategy: ANT_PATH_MATCHER

✅ 端口没开(Debian 防火墙)

sudo ufw status
sudo ufw allow 8080

✅ 绑定地址问题

server:
  address: 0.0.0.0

二、你是「Node.js + Swagger(Express / NestJS)」

1. 本地访问

http://localhost:3000/api-docs

2. 查看进程

ps aux | grep node
netstat -tunlp | grep 3000

3. 常见错误

  • CORS 问题(前端打不开)
  • yaml/json 写错导致启动失败

三、你是「用 Docker 跑 Swagger」

docker ps
docker logs swagger-container

访问:

http://<服务器IP>:8080

四、通用调试命令(Debian)

# 看端口
ss -tunlp

# 看进程
ps aux | grep java
ps aux | grep node

# 看网络
curl -v http://localhost:8080/swagger-ui.html

五、如果你告诉我这些,我能更精确帮你

  1. 用的是 Spring Boot / Node / Python / Go?
  2. Swagger 版本(2 / 3 / OpenAPI)
  3. 报错截图或日志
  4. 是页面打不开还是接口不显示

你可以直接贴一段日志,我帮你逐行看。

0 踩