【发布时间】:2013-08-12 00:20:45
【问题描述】:
我正在使用 Spring 3.1 JSF 2.2。
使用 JSF 2.2 引入的 ViewScoped 注释 Bean 不起作用。
@javax.inject.Named
@javax.faces.view.ViewScoped
public class TestBean {
@PostConstruct
public void init(){sysout("Why spring invoke this when initializing context :-( ");}
}
在我的applicationContext.xml中有一个注解组件扫描标签
<context:component-scan base-package="com.test"/>
Spring 3.1 检测并处理 CDI 注释,但 @javax.faces.view.ViewScoped 不起作用。我知道有 another solution 通过创建我自己的 ViewScoped 实现,但我想知道为什么 @javax.faces.view.ViewScoped 不起作用
【问题讨论】:
-
为什么你认为 spring 调用
@PostConstruct?您没有在此代码中使用 Spring。请详细说明您的问题。需要sscce。
标签: spring jsf jsf-2 cdi jsf-2.2