在 Debian 上“调试 Swagger”通常分几种场景,我先按最常见情况给你说明,你再对照自己的环境:
systemctl status your-service
# 或
ps aux | grep java
ss -lntp | grep 8080
浏览器访问:
http://服务器IP:端口/swagger-ui.html
或
http://服务器IP:端口/swagger-ui/index.html
依赖:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>
访问:
/swagger-ui/index.html
/v3/api-docs
调试:
tail -f logs/xxx.log | grep -i swagger
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
问题常见原因:
@EnableSwagger2location /swagger-ui/ {
proxy_pass http://127.0.0.1:8080/;
}
测试配置:
nginx -t
systemctl reload nginx
查看错误:
tail -f /var/log/nginx/error.log
curl http://localhost:8080/v3/api-docs
/v3/api-docs 是否 404 / 500| 现象 | 原因 |
|---|---|
| 白屏 | JS/CSS 被 Nginx 拦截 |
| 404 | 路径错误 |
| 500 | Controller 扫描失败 |
| 无接口 | 没加 @RestController |
| CORS | 跨域未配置 |
你可以直接告诉我:
我可以直接给你精准修复命令。