【发布时间】:2018-10-05 05:35:06
【问题描述】:
我在Spring boot 中开发了一个API。为了方便起见,我使用 Swagger2 并有目的地使用technical doc。
现在,我遇到了一个主要是我们整个 API 引起的问题。
它经常打印日志。大约 1 分钟。创建 2-5 MB 日志。这是绝对不能接受的。由于下面提到的错误。
我坚信,这是因为 Swagger UI 配置。它正在出现。
org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /null/swagger-resources/configuration/security
org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /null/swagger-resources
org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /null/swagger-resources/configuration/ui
我已经从我的“Authentication/Authorization”validation 检查中绕过以下endpoints。
1. /swagger-ui.html
2. /v2/api-docs
3. /swagger-resources/configuration/ui
4. /swagger-resources
5. /swagger-resources/configuration/security
问题是,为什么它在内部调用以/null 前缀开头的端点(请参阅上面提到的在我的日志中打印的 3 个错误语句)
外衣!很有趣! 对我来说,这件事发生(导致)只发生在我的一个environment(DEV, TEST, PROD) 中。而在其他environment 中,它工作得非常好,不会抛出任何此类errors。
注意 - 我只在DEV & LOCAL env. 中启用了swagger。可能是由于这个原因,它没有分别在TEST & PROD 中给出任何error。我再次不确定发生了什么问题。
即使,在我的本地也没有给出任何错误!
我正在使用以下 maven 依赖项来启用 swagger,
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
任何帮助将不胜感激!!
【问题讨论】:
-
您找到解决方案了吗?
-
@JoseMartinez 是的...实际上,有人对我的 API 进行了攻击,我已将其(ID 地址)从服务器端添加到我的黑名单中。所以现在没有更多的错误......
标签: java spring-boot swagger swagger-ui swagger-2.0