Spring security 这是什么原因造成的;“拒绝访问”;错误?
我运行时遇到“拒绝访问”错误 以下是我的安全配置:Spring security 这是什么原因造成的;“拒绝访问”;错误?,spring-security,Spring Security,我运行时遇到“拒绝访问”错误 以下是我的安全配置: @Override protected void configure(HttpSecurity http) throws Exception { http.cors().and().csrf().disable().authorizeRequests() .antMatchers(HttpMethod.POST, SIGN_UP_URL).permitAll() .anyRequest(
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable().authorizeRequests()
.antMatchers(HttpMethod.POST, SIGN_UP_URL).permitAll()
.anyRequest().authenticated()
.and()
.addFilter(new JWTAuthenticationFilter(authenticationManager()))
.addFilter(new JWTAuthenticationVerificationFilter(authenticationManager()))
// this disables session creation on Spring Security
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
常数是
public static final String SIGN_UP_URL = "api/user/create";
我的整个项目是
我不太确定我在这里做错了什么。注册URL中缺少开始斜杠…此外,如果在注册URL中添加
/
,它将修复当前spring boot版本的问题将spring boot升级到2.3.4没有帮助。添加结尾斜杠也是一样。我在本地运行了您的项目,它对我来说运行良好。您使用的是哪个IDE?您是否重新加载了依赖项并编译了项目(IDE应该自动编译),但请试一试。我使用的是ItelliJ思想。我使缓存失效并重新启动。也许我应该试着重新启动我的电脑。