Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 如何@autowire到jsf托管bean中_Spring_Jsf_Ioc Container_Autowired - Fatal编程技术网

Spring 如何@autowire到jsf托管bean中

Spring 如何@autowire到jsf托管bean中,spring,jsf,ioc-container,autowired,Spring,Jsf,Ioc Container,Autowired,要使用@Autowire注释,使用注释的对象必须来自spring上下文 JSF托管bean是由JSF的IOC而不是Spring创建的,因此我不能在其中使用@Autowire,必须使用faces-config.xml和托管属性 我已经设置了一个EL解析器,让它可以将Springbean作为托管属性,我想更进一步,不再需要每次需要自动连接某些内容时都进入faces-config.xml。这可能吗?只需使用@Controller(或@Component)和@Scope(“请求”)(或会话)注释托管be

要使用@Autowire注释,使用注释的对象必须来自spring上下文

JSF托管bean是由JSF的IOC而不是Spring创建的,因此我不能在其中使用@Autowire,必须使用faces-config.xml和托管属性


我已经设置了一个EL解析器,让它可以将Springbean作为托管属性,我想更进一步,不再需要每次需要自动连接某些内容时都进入faces-config.xml。这可能吗?

只需使用
@Controller
(或
@Component
)和
@Scope(“请求”)
(或
会话
)注释托管bean并添加
(如果没有),托管bean将自动检测为spring bean。既然您已经在使用ELResolver,那就应该是它了——您应该能够使用
@Autowired
(或者更好地使用
@Inject
,如果使用spring 3.0)。

您可以使用@ManagedProperty(#{'someBean'))对于jsf bean中的autowire其他bean

你是说我应该从faces-config.xml中完全删除托管bean吗?@Bozho在jsf 2中,新的视图范围真的很有用吗spring为bean提供了该范围???@Necronet-不,spring没有这个范围。如何在JSF和spring之间实现这样的集成,从而支持这个范围,这是一个很好的问题。我不知道答案。@Bozho-我相信如果使用org.springframework.web.jsf.springbeanvariablesolver,您可以通过faces注入bean。好的,使用解析器,您可以将jsf的托管bean功能“交给”spring。所以我认为它不起作用。可能是