1. 程式人生 > >Requested bean is currently in creation: Is there an unresolvable circular reference?

Requested bean is currently in creation: Is there an unresolvable circular reference?

如下:

@Bean//登陸攔截器
 public CustomAuthenticationProcessingFilter customAuthenticationProcessingFilter() throws Exception {
     CustomAuthenticationProcessingFilter customAuthenticationProcessingFilter=new CustomAuthenticationProcessingFilter();
     customAuthenticationProcessingFilter.setAuthenticationManager(authenticationManagerBean());
     customAuthenticationProcessingFilter.setAuthenticationSuccessHandler(new CustomAuthenticationSuccessHandler());//自定義成功處理
     customAuthenticationProcessingFilter.setAuthenticationFailureHandler(new CustomAuthenticationFailureHandler());//自定義失敗處理
     return customAuthenticationProcessingFilter;
 }
 @Autowired//登陸攔截器
 private CustomAuthenticationProcessingFilter customAuthenticationProcessingFilter;

會報錯。

 

可能是同時都是建立,所以衝突了,導致迴圈

 

刪掉 @Autowired//登陸攔截器 private CustomAuthenticationProcessingFilter customAuthenticationProcessingFilter;