简体   繁体   中英

Handle spring bean failures in java application

我对Spring Framework完全陌生。我正在开发一个针对传入请求进行两种身份验证的应用程序。在bean.xml中,我有两种类型的身份验证处理程序。我的要求是,如果一个身份验证处理程序失败,它应该不会中断,而应该继续进行下一个身份验证处理程序。我该如何实现呢?我们可以在bean.xml中指定吗,如果处理程序抛出异常,spring执行应该不会失败并且应该继续执行下一个身份验证。

Since you are unable to post your bean.xml file , I am assuming you have declared your authentication managers like:

<security:authentication-manager>
  <security:authentication-provider ref="AAuthProvider" />
  <security:authentication-provider ref="BAuthProvider" />
</security:authentication-manager>

By default, spring is designed to evaluate the handlers in a linear fashion. Meaning, they will be evaluated in order. If one fails, it automatically goes to the next one.

References:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM