对于 HttpSecurity 类型,方法 and() 未定义
The method and() is undefined for the type HttpSecurity
我正在尝试遵循此 example 这基本上是一些代码,实际上使 angular.js 上的登录无效。
我得到"The method and() is undefined for the type HttpSecurity"
这是我的部分 Code(第 89 行):
@EnableWebMvcSecurity
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic()
.and().authorizeRequests()
.antMatchers("/login", "/error" , "/error.html")
.permitAll()
.anyRequest()
.fullyAuthenticated()
/*.permitAll().anyRequest().authenticated()*/
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/")
.permitAll()
.and()
.csrf().csrfTokenRepository(csrfTokenRepository())
.and()
.addFilterAfter(csrfHeaderFilter(), CsrfFilter.class)
.and() /* HERE IS WHERE I GET THE WARNING */
.sessionManagement()
.maximumSessions(1)
.expiredUrl("/expired")
.maxSessionsPreventsLogin(true)
.sessionRegistry(sessionRegistry());
}
...more code here
}
addFilterAfter()
已经是 returns HttpSecurity
的一个实例,因此您可以直接调用 sessionManagement()
而无需先调用 and()
。
我正在尝试遵循此 example 这基本上是一些代码,实际上使 angular.js 上的登录无效。
我得到"The method and() is undefined for the type HttpSecurity"
这是我的部分 Code(第 89 行):
@EnableWebMvcSecurity
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic()
.and().authorizeRequests()
.antMatchers("/login", "/error" , "/error.html")
.permitAll()
.anyRequest()
.fullyAuthenticated()
/*.permitAll().anyRequest().authenticated()*/
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/")
.permitAll()
.and()
.csrf().csrfTokenRepository(csrfTokenRepository())
.and()
.addFilterAfter(csrfHeaderFilter(), CsrfFilter.class)
.and() /* HERE IS WHERE I GET THE WARNING */
.sessionManagement()
.maximumSessions(1)
.expiredUrl("/expired")
.maxSessionsPreventsLogin(true)
.sessionRegistry(sessionRegistry());
}
...more code here
}
addFilterAfter()
已经是 returns HttpSecurity
的一个实例,因此您可以直接调用 sessionManagement()
而无需先调用 and()
。