在ShiroConfig这样配置拦截器
filter.put("/swagger-ui.html", "anon");
filter.put("/swagger/**","anon");
filter.put("/swagger-resources/**", "anon");
filter.put("/v2/**", "anon");
filter.put("/webjars/**", "anon");
filter.put("/configuration/**", "anon");
filter.put("/doc.html","anon");
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean shiroFilter(DefaultWebSecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
shiroFilter.setSecurityManager(securityManager);
Map<String, String> filter = new LinkedHashMap<>();
filter.put("/authenticate/login", "anon");
filter.put("/swagger-ui.html", "anon");
filter.put("/swagger/**","anon");
filter.put("/swagger-resources/**", "anon");
filter.put("/v2/**", "anon");
filter.put("/webjars/**", "anon");
filter.put("/configuration/**", "anon");
filter.put("/doc.html","anon");
filter.put("/**", "authc,roles[ADMIN]");
shiroFilter.setFilterChainDefinitionMap(filter);
return shiroFilter;
}
这样就可以成功访问了!
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/49335b399f767af3ced796e8bdb4725a.gif#pic_center)