下到了老师给的源码,是用MyEclipse建的项目,把applicationContext.xml放在了WebContent/WEB-INF/config/目录下,然后再JUnit测试用@ContextConfiguration("classpath:**/application*.xml")诸如配置文件,报错
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.ce.spring.transaction.demo1.SpringDemo1': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'accountService' is defined
这是我的项目结构
不要将配置文件放到WEB-INF下面,不再classpath上
classpath:applicationContext.xml (对应的xml文件名)
路径问题,改成这样应该就好了