我新与注释,我想JS(2.0)弹簧(3.1)集成,我可以整合这两个framewoks,但我没有JSF的viewScope因为它不是'可用。我想使用注释在jsf managedBean中自动注入spring bean,但是我不能因为Spring只支持会话并请求范围bean。指定弹簧豆与注释
我使用一个Util类来检索bean。 “SprigUtil.getBean( '豆')”。当我需要的时候手动撤销弹簧豆。
我想要做一些这样的
@CustomAnnotation( 'beanTest') 私人豆豆;
因此,bean Atributte将被设置为beanTest bean。
我的目标(姑且弹簧)也知道该怎么做了一些类似这样的
@assing(“家”) 私人字符串的地方;
当我调用getMethod获取“House”时。 instance.getPlace()返回'House'
注意: 我知道@Autowired,但我不能使用它,因为ViewScope在spring-jsf集成中不可用。 我读过关于手动实现视图范围,但想尝试不同的解决方案。
编辑:
我FacesConfig:
我FacesConfig:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1">
<application>
<el-resolver> org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
</application>
</faces-config>
而且我appContext
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="*" />
</beans>
我的Spring bean
@Component
public class ProductService{
}
我的Managed Bean的
@Component
@Scope("request")//I need to use @Scope("view") but it doesn't exist
public ProductBean implements Serializable{
@Autowired
ProductService productoService;
}
如果我使用JSF的注解@ManagedBean和@ViewScoped productService没有注入(为null)
能否请您展示您的spring applicationContext? – shevchyk 2013-02-21 22:53:30