spring boot整合spring security访问接口无响应

状态:

通过浏览器发送访问请求:

localhost:9000/files/download在这里插入图片描述

输入user和密码

在这里插入图片描述

密码如果不设置在启动的时候控制台会有

Using generated security password: 75a2959a-522c-4335-830d-d247e7b4743b

会正常访问

在这里插入图片描述

解决方式

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    
    

    @Override
    public void configure(WebSecurity web) throws Exception {
    
    
        //忽略权限授权接口,填写路径就好
        web.ignoring().antMatchers("/sysUsers/*", "/auth/*", "/files/*");
    }

//    @Override
//    public void configure(HttpSecurity http) throws Exception {
    
    
////         任意请求允许无授权访问
//        http.authorizeRequests()
//                .anyRequest().permitAll();
////        http.csrf().disable().exceptionHandling().authenticationEntryPoint(getAccessDeniedHandler());
//    }
}

猜你喜欢

转载自blog.csdn.net/weixin_42096620/article/details/111525729