您必须使用绝对模式,请参阅
AntPathMatcher:
注意: 模式和路径必须都是绝对的,或者都必须是相对的,才能使两者匹配。因此,建议该实现方式的用户清理模式,以便在模式使用的前缀中以“
/”作为前缀。
您修改和简化的配置:
@Overrideprotected void configure(HttpSecurity http) throws Exception { http .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .csrf().disable() .authorizeRequests() .antMatchers(HttpMethod.POST, "authenticate").permitAll() .antMatchers(HttpMethod.GET, "get-public-key").permitAll() .antMatchers(HttpMethod.OPTIONS, "/**").permitAll() .anyRequest().authenticated();}


