views:

137

answers:

1

I'm using class that is not called by my @Controller directly and when I try to use @Autowired propeprty in that class what is defined as @Service, property is null. But @Autowired with same markup will work inside @Controller.

Example code:

@Service
public class UsernameValidator implements Validator {

    @Autowired private UserDao userDao;

    // code here when used, userDao is always null

}
+1  A: 

This should work perfectly fine, if you have the following in your applicationContext.xml:

<context:component-scan  base-package="com.yourproject" />
Bozho