问题描述
maven打包时出现了这个错误
找到test,错误是
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.jxb.common.security.CustomUsernamePasswordAuthenticationFilter]: Factory method 'usernamePasswordAuthenticationFilter' threw exception; nested exception is java.lang.StackOverflowError
@Bean
public CustomUsernamePasswordAuthenticationFilter usernamePasswordAuthenticationFilter() throws Exception {
CustomUsernamePasswordAuthenticationFilter usernamePasswordAuthenticationFilter = new CustomUsernamePasswordAuthenticationFilter();
usernamePasswordAuthenticationFilter.setAuthenticationManager(authenticationManagerBean());
return usernamePasswordAuthenticationFilter();
}
原因分析:
返回值写错了,应该写usernamePasswordAuthenticationFilter ,结果写成了
usernamePasswordAuthenticationFilter(),递归调用了,栈溢出