UsernamePasswordAuthenticationFilter
ObjectMapper
@RequiredArgsConstructor
在我们写controller或者Service层的时候,需要注入很多的mapper接口或者另外的service接口,这时候就会写很多的@AutoWired注解,代码看起来很乱lombok提供了一个注解:
@RequiredArgsConstructor(onConstructor =@_(@Autowired))
写在类上可以代替@AutoWired注解,需要注意的是在注入时需要用final定义,或者使用@notnull注解
.addFilterAt
.addFilterAt(restAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
设置
private RestAuthenticationFilter restAuthenticationFilter() throws Exception {RestAuthenticationFilter filter = new RestAuthenticationFilter(objectMapper);filter.setAuthenticationSuccessHandler(jsonLoginSuccessHandler());filter.setAuthenticationFailureHandler(jsonLoginFailureHandler());filter.setAuthenticationManager(authenticationManager());filter.setFilterProcessesUrl("/authorize/login");return filter;}
