所有的注解看起来都没有任何问题,最后是由于web-xml配置问题。

由于缺少监听器org.springframework.web.context.ContextLoaderListener,

导致无法自动装配配置文件信息。

所以应该在web-xml中加入

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

ContextLoaderListener的作用就是启动Web容器时,所以启动spring的监听器,这样配置在xml文件中的bean才会初始化

相关文章:

  • 2022-12-23
  • 2021-11-08
  • 2021-07-21
  • 2021-07-22
  • 2022-02-08
  • 2021-05-31
  • 2021-12-21
  • 2021-12-02
猜你喜欢
  • 2021-04-10
  • 2021-09-01
  • 2021-04-22
  • 2022-12-23
  • 2021-12-15
  • 2021-09-30
  • 2021-04-04
相关资源
相似解决方案