Java Spring boot中的SecurityProperty
尝试使用JWT(JSON Web令牌)创建具有用户身份验证的应用程序。但是,当我开始配置WebSecurityConfig.java时,我遇到了下一个问题:Java Spring boot中的SecurityProperty,java,spring,spring-boot,spring-security,jwt,Java,Spring,Spring Boot,Spring Security,Jwt,尝试使用JWT(JSON Web令牌)创建具有用户身份验证的应用程序。但是,当我开始配置WebSecurityConfig.java时,我遇到了下一个问题: @Override protected void configure(HttpSecurity http) throws Exception { String[] permited = new String[security.getIgnored().size()]; security.getIgnored().toArra
@Override
protected void configure(HttpSecurity http) throws Exception {
String[] permited = new String[security.getIgnored().size()];
security.getIgnored().toArray(permited);
http
.csrf().disable()
.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests()
.antMatchers("/api/authenticate").permitAll()
.antMatchers("/api/user").permitAll()
.antMatchers("/").permitAll()
.antMatchers("/favicon.ico").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginProcessingUrl("/api/authentication")
.successHandler(ajaxAuthenticationSuccessHandler)
.failureHandler(ajaxAuthenticationFailureHandler)
.usernameParameter("username")
.passwordParameter("password")
.and()
.logout()
.logoutUrl("/api/logout")
.logoutSuccessHandler(ajaxLogoutSuccessHandler)
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID");
http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
http.headers().cacheControl();
}
它告诉我它“无法解析方法getIgnored()”。这只是这种方法的最初几点尝试
我知道在spring中有两个同名的类:
(一)
(二)
所以我需要第二个类的getIgnored()方法。请帮我完成这个过程。我知道这可能是一个愚蠢的问题,但我感谢任何帮助
顺便说一下,这就是我如何用@Autowired anotation定义“安全性”:
@Autowired
SecurityProperties security;
这不是两个不同的类,而是不同版本的相同类
getIgnored
方法已被删除。请参见您的依赖关系可能有点混乱。您需要严格遵守Spring Boot 2中的规定。你需要发布你的Pom以便我们提供帮助。我明白了。谢谢!