I got this exception. This is my code:
ApplicationContext context = new ClassPathXmlApplicationContext(\"classpath*:/servlet-context.xml\");
UserDao userDao = (U
classpath*:/servlet-context.xml
will load every servlet-context.xml
resource from the root of your application's classpath.
/myproject/WebContent/WEB-INF/spring/appServlet/servlet-context.xml
, however, isn't on the classpath root at all, and so Spring will ignore your file and build an empty context.
Try moving servlet-context.xml
to be directly under WEB-INF/classes
(i.e. to WEB-INF/classes/servlet-context.xml
).
Alternatively, move it to WEB-INF/classes/spring/appServlet/servlet-context.xml
, and change your code to classpath*:/spring/appServlet/servlet-context.xml