Caused by:.NoSuchBeanDefinitionException: No bean named 'userInfoServiceImpl' available

-小丁-發表於2018-10-24

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘userInfoServiceImpl’ available
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1213)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)… 60 more

解決辦法:
在使用Spring框架的時候,沒有生命元件掃描器,沒有把 service實現層 的註解沒有掃描。 所以要在applicationContext.xml中宣告元件掃描器
<context:component-scan base-package=“有service註解的包名”/>

相關文章