I can't seem to get my servlet's fields to @AutoWire; they end up null. I have a pure annotation-configured webapp (no XML files). My servlet looks like this:
@WebServlet("/service")
public
class
SatDBHessianServlet
extends HttpServlet
{
@Autowired protected NewsItemDAO mNewsItemDAO;
}
Other @AutoWired things seem to work fine, both @Service objects and @Repository objects. But not this one, and I can't figure out why. I even tried adding its package to the ComponentScan(basePackages) list for my other classes.
Additional Info:
I added the following to my servlet’s init() method, and everything seemed to wire up properly, but I'm confused as to why Spring can't wire it up without that.
SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, inConfig.getServletContext());