2024年6月26日 关闭swagger,禁止访问
This commit is contained in:
parent
1cf148a66c
commit
91103a119f
|
@ -20,6 +20,7 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
|
@ -51,6 +52,13 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||||
@Value("${spring.resource.static-locations:}")
|
@Value("${spring.resource.static-locations:}")
|
||||||
private String staticLocations;
|
private String staticLocations;
|
||||||
|
|
||||||
|
@Value("${knife4j.production}")
|
||||||
|
private boolean knife4jIsProduction;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private PrometheusMeterRegistry prometheusMeterRegistry;
|
private PrometheusMeterRegistry prometheusMeterRegistry;
|
||||||
|
|
||||||
|
@ -73,7 +81,13 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
registry.addViewController("/").setViewName("doc.html");
|
//如果开启了swagger直接跳过去,如果没开,直接让它404
|
||||||
|
if(!knife4jIsProduction){
|
||||||
|
registry.addViewController("/").setViewName("doc.html");
|
||||||
|
} else {
|
||||||
|
registry.addViewController("/").setStatusCode(HttpStatus.NOT_FOUND);
|
||||||
|
registry.addViewController("/doc.html").setStatusCode(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -250,7 +250,7 @@ knife4j:
|
||||||
#开启增强配置
|
#开启增强配置
|
||||||
enable: true
|
enable: true
|
||||||
#开启生产环境屏蔽
|
#开启生产环境屏蔽
|
||||||
production: false
|
production: true
|
||||||
basic:
|
basic:
|
||||||
enable: true
|
enable: true
|
||||||
username: jeecg
|
username: jeecg
|
||||||
|
|
Loading…
Reference in New Issue