我正在尝试将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 获得 null someService;它不会注入任何值。这是返回我们的错误:
javax.servlet.ServletException: JBAS011048: No logró construir la instancia del componente javax.faces.webapp.FacesServlet.service(FacesServlet.java:606).
谁能告诉我如何正确地做到这一点。提前谢谢。
我们依赖以下链接:Spring JSF 集成:如何在 JSF 管理的 Bean 中注入 Spring 组件/服务?
@Autowired 未注入受管 Bean 中的弹簧服务
看看这篇文章,以便将 spring 与 JSF 集成。