我正在尝试将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获取someService的null;它没有注入任何价值。 这是给我们的错误:
javax.servlet.ServletException:JBAS011048:Nologróconsitirla 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?