我試圖創建一個bean,比試圖注入同樣在我的控制器,但我得到的bean創建失敗error.Here是我的代碼創建bean失敗(春季)
@Service("springSecurityLoginServiceImpl")
public class SpringSecurityLoginServiceImpl implements SpringSecurityLoginService
{
//impl
}
這是怎麼了我試圖在我的控制器注入它
@Controller
@RequestMapping("springSecurity/login.json")
public class SpringSecurityLoginController
{
@Autowired
@Qualifier("springSecurityLoginServiceImpl")
SpringSecurityLoginService springSecurityLoginService;
}
有除了這些註解Spring的MVC-配置xml文件中沒有條目,但是當我開始服務器面臨以下異常
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0'
defined in ServletContext resource [/WEB-INF/config/spring-mvc-config.xml]:
Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'springSecurityLoginController':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: com.core.servicelayer.user.SpringSecurityLoginService com.storefront.controllers.pages.SpringSecurityLoginController.springSecurityLoginService;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No matching bean of type [com.core.servicelayer.user.SpringSecurityLoginService] 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),
@org.springframework.beans.factory.annotation.Qualifier(value=springSecurityLoginServiceImpl)}
我不知道我做錯了還是什麼額外的我必須做
你可以在spring-mvc-config.xml中顯示你正在使用的組件掃描標籤嗎? – gkamal