Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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
在JSF和Spring中解析支持bean的可能性_Spring_Jsf_El - Fatal编程技术网

在JSF和Spring中解析支持bean的可能性

在JSF和Spring中解析支持bean的可能性,spring,jsf,el,Spring,Jsf,El,我在我的jsf+Spring应用程序中使用了org.springframework.web.jsf.el.SpringBeanFacesELResolver。每个支持bean都需要解析一个接口。我猜这是依赖注入的接口类型 #{bean.text} public interface IBean { String getText(); } @Named @Scope("session") public class Bean implements IBean { public St

我在我的jsf+Spring应用程序中使用了
org.springframework.web.jsf.el.SpringBeanFacesELResolver
。每个支持bean都需要解析一个接口。我猜这是依赖注入的接口类型

#{bean.text}

public interface IBean {
    String getText();
}

@Named
@Scope("session")
public class Bean implements IBean {
    public String getText() {
        return "Hello World!";
    }
}

我想摆脱这个界面。对我来说,这是一种官僚主义。有可能吗?我终于解决了。问题出在范围取决于HTTP(请求、会话)的bean中。默认情况下,应手动创建接口。这可以通过使用代理来避免

如果使用组件扫描:

<context:component-scan base-package="..." scoped-proxy="targetClass" />

或者在bean定义中:

<bean ...>
    <aop:scoped-proxy>
</bean>


如果您不想实现,则不必实现接口。在继续之前,您可能应该阅读本文,顺便说一下,您没有将任何属性注入Bean类。下面是一个让您开始学习的方法。@Ravi:Tho问题在于Spring默认解决了范围为会话或请求的bean的依赖关系。看看我的答案。