org.springframework.beans.factory.NoSuchBeanDefinitionException


我是直接把配置文件複製到項目中的;

然後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



發佈了50 篇原創文章 · 獲贊 4 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章