出现org.springframework.beans.factory.BeanCreationException: Error creating bean with name :XXX异常

 

 

 

出现org.springframework.beans.factory.BeanCreationException: Error creating bean with name :XXX异常

 

出现问题:web.xml配置文件中没有配置applicationContext.xml文件导致applicationContext.xml文件中扫描注解代码没有触发

 

 

解决办法:在Web.xml文件中配置

 初始化applicationContext.xml配置文件

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>