http.sessionManagement() // SpringSecurity不会使用也不会创建HttpSession实例 .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests() // swagger请求 .antMatchers("/swagger-ui.html", "/webjars/**", "/swagger-resources/**","/v2/**").permitAll() // 所有请求,都需要有all范围(scope) .antMatchers("/**").access("#oauth2.hasScope('xxx')").anyRequest().authenticated().and().csrf() .disable();