Fixing Null EntityManger in Spring MVC application?
问题 In the following code I am trouble with my injected EnitityManager, which always shows up as null ; public class GenericController extends AbstractController { @PersistenceContext(unitName = "GenericPU") private EntityManager em; protected ModelAndView handleRequestInternal( HttpServletRequest request, HttpServletResponse response) throws Exception { //(em == null) is always trigged if (em == null) throw new NullPointerException("em is null"); Collection<Generic> Generics = em