【发布时间】:2016-01-26 23:39:08
【问题描述】:
我正在尝试将 Spring 与 JSF 集成。
@ManagedBean
@ViewScoped
public class SomeBean() implements Serializable{
@Autowired
private SomeService someService; // with get and set
...
@PostConstruct
public void init() {
FacesContextUtils
.getRequiredWebApplicationContext(FacesContext.getCurrentInstance())
.getAutowireCapableBeanFactory().autowireBean(this.someService);
}
}
@Service
public class SomeServiceImpl implements SomeService{
@Autowired
SomeDao someDao;
...
}
我总是从 bean 中获取一些服务为空;它没有注入任何价值。 这是返回给我们的错误:
javax.servlet.ServletException: JBAS011048: No logró construir la instancia del componente javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)。
谁能告诉我如何正确执行此操作。在此先感谢。
我们依赖以下链接: Spring JSF integration: how to inject a Spring component/service in JSF managed bean?
【问题讨论】:
标签: spring jsf service javabeans autowired