Shiro 访问 Swagger2报404 及 放行Swagger2
//放行Swagger2页面,需要放行这些 map.put("/swagger-ui.html","anon"); map.put("/swagger/**","anon"); map.put("/webjars/**", "anon"); map.put("/swagger-resources/**","anon"); map.put("/v2/**","anon"); //filterChainDefinitionMap.put("/static/**", "anon");
404:
@Configuration public class WebConfig implements WebMvcConfigurer { //解决 No mapping for GET /favicon.ico 访问静态资源图标 public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/**") .addResourceLocations("classpath:/static/"); //下面解决swagger_ui.html报404的错误。 registry.addResourceHandler("swagger-ui.html") .addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**") .addResourceLocations("classpath:/META-INF/resources/webjars/"); } }
参考:
https://blog.csdn.net/weixin_42036952/article/details/90298357
道法自然