How to integrate Spring and JSF? I followed Spring documentation (which is sparse on this subject) and googled some more and currently I found two working ways:
JSF Managed Bean will be Spring @Component / @Named (but there doesn't seem to work JSF scopes, but only Spring scopes):
@Component @Scope("request") public class ItemController { @Autowired private ItemService itemService; }
I will use @ManagedBean, JSF scopes work, but I cannot autowire Spring bean using @Autowired, the bean must contain setter and I'm not sure if this is best practice:
@ManagedBean @RequestScoped public class ItemController { @ManagedProperty("#{itemService}") private ItemService itemService; public void setItemService(ItemService itemService) { this.itemService = itemService; } }
Something else?