我是直接把配置文件複製到項目中的;
然後junit測試,一直提示報錯:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.lian.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
剛開始不知道什麼原因,打開配置文件的時候,發現 掃描包的信息忘記改了;
註解掃描不到你的bean,當然會報NoSuchBeanDefinitionException