有人说组件扫描@ComponentScan没有扫到@Service,或者jdk版本的问题,或者是userService大小写以及字符错误,后来我发现都不是。我的问题是这句代码:
ApplicationContext app = new AnnotationConfigApplicationContext("SpringConfiguration.class");
正确代码:
ApplicationContext app = new AnnotationConfigApplicationContext(SpringConfiguration.class);
在引用文件类型时不要打引号,引号是通过键取值。



