如何将@autowire转换为jsf托管bean

mko*_*yak 6 jsf spring ioc-container autowired

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

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

我已经设置的EL解析器,让是有春天豆类管理特性,我希望把它一步,摆脱需要每一个我需要的东西自动装配时间去到faces-config.xml中.这可能吗?

Boz*_*zho 12

只需用@Controller(或@Component)和@Scope("request")(或session)添加<context:component-scan>(如果没有)注释您的托管bean ,托管bean将自动被检测为spring bean.既然你已经在使用ELResolver,那应该是它 - 你应该能够使用@Autowired(或者更好 - @Inject如果使用spring 3.0).