如果你已经有了Spring容器,为什么不使用其@Autowired注释。为此,请按照Boni的建议更新你的faces-config.xml。然后将这些侦听器添加到你的web.xml中
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value></context-param><listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class></listener>
然后将它们添加到你的applicationContext.xml
<context:component-scan base-package="com.examples" />
现在你可以使用Spring批注,你的bean将会像这样:
package com.examples;@Component@Scope(value="request")public class MyBean { @Autowired private MySpringBeanClass mySpringBean;}用@Service注释MySpringBeanClass



