Hi all,
I'm a little bit confused about the right autowiring strategy. I've a servlet application with JSF and that stuff. In my applicationContext.xml I placed the following construct:
With that configuration I assume that all classes in these packages are scanned for @Component or @Service an the like. Now, in de.myproject.managedbeans I placed a managed bean for a JSF view:Code:<context:component-scan base-package="de.myproject.service,de.myproject.managedbeans,de.myproject.menu" />
The class MyMenuModel looks like following:Code:@ManagedBean @SessionScoped public class MenuBean { @Autowired private MyMenuModel menuModel; @ManagedProperty(value = "#{userService}") private UserService userService; public MenuBean() {} /** * @param menuModel */ @Autowired public MenuBean(MyMenuModel menuModel) { this.menuModel = menuModel; } // some other stuff... }
This bean is instantiated correctly. My problem is that in the MenuBean class the property menuModel is null. Whereas userService is wired correctly. I really don't know what's wrong with this. Helpful answers are welcome...Code:@Component public class MyMenuModel implements MenuModel, ActionListener, Serializable { @Autowired private MyFirstRepository myFirstRepository; public MyMenuModel () {} /** * @param myFirstRepository */ @Autowired public MyMenuModel(MyFirstRepository myFirstRepository) { this.myFirstRepository= myFirstRepository; } // some other stuff... }
TIA,
Ralf.


Reply With Quote