Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

springcloud 生产环境无法关闭 #338

Closed
tinarooot opened this issue May 24, 2021 · 7 comments
Closed

springcloud 生产环境无法关闭 #338

tinarooot opened this issue May 24, 2021 · 7 comments

Comments

@tinarooot
Copy link

swagger.production=true

网关使用的 gateway

@xiaoymin
Copy link
Owner

这个特性是基于Servlet体系中的Filter实现的,目前的knife4j版本 都是knife4j.production,参考增强文档

而gateway不是Servlet体系,要实现生产环境关闭方法不要太多,简单的不能再简单了,几种思路:
1、Spring Boot提供的Conditional条件注入方法,生产profile不注入Swagger的配置Bean
2、网关层就算是Gateway也可以写过滤器的,基于URL的拦截和Servlet体系差不多

@tinarooot
Copy link
Author

这个特性是基于Servlet体系中的Filter实现的,目前的knife4j版本 都是knife4j.production,参考增强文档

而gateway不是Servlet体系,要实现生产环境关闭方法不要太多,简单的不能再简单了,几种思路:
1、Spring Boot提供的Conditional条件注入方法,生产profile不注入Swagger的配置Bean
2、网关层就算是Gateway也可以写过滤器的,基于URL的拦截和Servlet体系差不多

只能关掉接口,页面不知道关闭,请指点指点!!!

@xiaoymin
Copy link
Owner

这个特性是基于Servlet体系中的Filter实现的,目前的knife4j版本 都是knife4j.production,参考增强文档
而gateway不是Servlet体系,要实现生产环境关闭方法不要太多,简单的不能再简单了,几种思路:
1、Spring Boot提供的Conditional条件注入方法,生产profile不注入Swagger的配置Bean
2、网关层就算是Gateway也可以写过滤器的,基于URL的拦截和Servlet体系差不多

只能关掉接口,页面不知道关闭,请指点指点!!!

接口和页面都是访问地址,我不知道有什么区别呢?

@tinarooot
Copy link
Author

这个特性是基于Servlet体系中的Filter实现的,目前的knife4j版本 都是knife4j.production,参考增强文档
而gateway不是Servlet体系,要实现生产环境关闭方法不要太多,简单的不能再简单了,几种思路:
1、Spring Boot提供的Conditional条件注入方法,生产profile不注入Swagger的配置Bean
2、网关层就算是Gateway也可以写过滤器的,基于URL的拦截和Servlet体系差不多

只能关掉接口,页面不知道关闭,请指点指点!!!

接口和页面都是访问地址,我不知道有什么区别呢?

没思路

@xiaoymin
Copy link
Owner

一个接口访问地址是:/api/xxx,这种你能拦截控制吗?

然后换做一个地址/doc.html 这种不能拦截控制吗?或者更粗暴一点,把xxx-ui.jar包直接删掉好了,静态资源都没有了 怎么访问呢

@tinarooot
Copy link
Author

直接在swagger里面配置enable就开关swagger了

gateway里面配置的过滤器都不生效,有点崩溃

@xiaoymin
Copy link
Owner

直接在swagger里面配置enable就开关swagger了

gateway里面配置的过滤器都不生效,有点崩溃

我上面的回答你基本是看了,但是也就仅仅局限在看了一下,脑子里想都没想,这样我也很崩溃,我无法再回答这个issue了

@xiaoymin xiaoymin closed this as completed Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants