你这个问题比较简略,我分几种常见场景给你说明一下:在 Debian 上用 Swagger(OpenAPI) 时,常见的报错原因和排查方法。
现象
/swagger 或 /swagger-ui.html 报错可能原因
排查
systemctl status your-service
curl http://localhost:8080/swagger-ui.html
现象
Whitelabel Error Page
500 Internal Server Error
常见原因
@RestController@RequestMapping示例错误
org.springframework.context.ApplicationContextException:
Failed to start bean 'documentationPluginsBootstrapper'
典型报错
Unable to infer base url
Failed to load API definition
原因
@EnableOpenApi 或 @EnableSwagger2解决示例(Spring Boot 2.x)
@Configuration
@EnableSwagger2
public class SwaggerConfig {
}
Spring Boot 3.x 要用
springdoc-openapi-ui
netstat -tunlp | grep 8080
或
lsof -i:8080
journalctl -u your-service -n 50
常见错误:
Permission denied
Cannot create log file
报错示例:
Error: Cannot find module 'swagger-ui-express'
解决:
npm install swagger-ui-express
你可以直接贴出:
使用的技术栈
完整报错信息(关键几行即可)
Debian 版本
cat /etc/os-release
只要你把报错原文贴出来,我可以直接告诉你是哪一行配置或代码的问题 ✅