swagger-ui.html访问报错
在用swagger测试接口时,一直报错,但是查看了配置并没有问题,最后发现是shiro给拦截了。报错截图如下:
解决方案,在shiro中增加swagger相关的放行操作
@Beanpublic ShiroFilterChainDefinition shiroFilterChainDefinition() {
DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();chainDefinition.addPathDefinition("/static/**", "anon");chainDefinition.addPathDefinition("/files/**", "anon");chainDefinition.addPathDefinition("/global/sessionError", "anon");/*swagger相关不拦截操作开始*/chainDefinition.addPathDefinition("/swagger-ui.html/**", "anon");chainDefinition.addPathDefinition("/swagger-resources/**", "anon");chainDefinition.addPathDefinition("/v2/api-docs", "anon");chainDefinition.addPathDefinition("/webjars/**", "anon");/*swagger相关不拦截操作结束*/chainDefinition.addPathDefinition("/kaptcha", "anon");chainDefinition.addPathDefinition("/preview/**", "anon");chainDefinition.addPathDefinition("/login", "anon");chainDefinition.addPathDefinition("/logout", "logout");chainDefinition.addPathDefinition("/**", "user");return chainDefinition;}