no bean named “userDao” is defined
问题 I got this exception. This is my code: ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:/servlet-context.xml"); UserDao userDao = (UserDao) context.getBean("userDao"); And this is my servlet-context.xml file located in /myproject/WebContent/WEB-INF/spring/appServlet/servlet-context.xml <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www