简体   繁体   English

如何使用Spring将依赖项注入javax.faces.context.ExceptionHandler?

[英]How can I inject dependencies into a javax.faces.context.ExceptionHandler using Spring?

I have a JSF application using PrimeFaces 6.2 and Spring 5.1.4. 我有一个使用PrimeFaces 6.2和Spring 5.1.4的JSF应用程序。 I read, that an exception handler can be defined in the faces-config.xml like this: 我读到,可以在faces-config.xml定义一个异常处理程序,如下所示:

<factory>
    <exception-handler-factory>my.package.MyExceptionHandlerFactory</exception-handler-factory>
</factory>

I wondered how I could get the dependencies injected into an ExceptionHandlerFactory and ExceptionHandler ? 我想知道如何将依赖项注入到ExceptionHandlerFactoryExceptionHandler

You can't do this out of the box. 您不能开箱即用。 It would be possible by creating an "spring aware" ExceptionHandlerFactory and create the ExceptionHandler instance via Spring but i would just get the beans manually in your ExceptionHandler like: Best way to manually pull a spring bean? 通过创建“弹簧感知”的ExceptionHandlerFactory并通过Spring创建ExceptionHandler实例,这是可能的,但是我只是在ExceptionHandler中手动获取Bean,如: 手动拉动Spring Bean的最佳方法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何为Spring Data JPA注入依赖项? - How i can inject dependencies for spring data jpa? 我可以在javax websocket中使用spring上下文吗? - Can I use the spring context in javax websocket? 如何使用Spring将依赖项注入HttpSessionListener? - How to inject dependencies into HttpSessionListener, using Spring? 我可以从struts动作注入多个spring依赖吗 - Can I inject multiple spring dependencies from struts actions 我可以在依赖的Spring TestExecutionListener中注入依赖吗? - Can I inject dependencies inside a custom Spring TestExecutionListener? Spring MVC ExceptionHandler和控制器上下文 - Spring MVC ExceptionHandler and the controller context 使用 spring 上下文在单元测试中自动装配 javax.inject.provider - Autowiring a javax.inject.provider in a unit-test with spring context 我可以使用Spring注入相同的类吗? - Can I inject same class using Spring? 将没有JSF依赖项的Spring项目部署到Payara会导致javax.faces.FacesException:无法找到CDI BeanManager - Deploying Spring project without JSF dependencies to Payara causes javax.faces.FacesException: Unable to find CDI BeanManager 无法让Spring注入我的依赖 - Can't get Spring to inject my dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM