Reputation: 24625
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
}
Upvotes: 1
Views: 1524
Reputation: 597006
This should work perfectly fine, if you have the following in your applicationContext.xml
:
<context:component-scan base-package="com.yourproject" />
Upvotes: 1