问题原因:
项目中存在2个配置文件:springMVC.xml和beanDefines.xml,它们都配置了<context:component-scan base-package="com" />。
在beanDefines.xml还配置了<task:annotation-driven/>。
从启动日志中发现,spring先加载的是beanDefines.xml,后加载的是springMVC.xml。
由于springMVC.xml的context:component-scan覆盖了beanDefines.xml的配置,而<task:annotation-driven/>是否有效是依赖于context:component-scan的配置的。
导致beanDefines.xml配置的<task:annotation-driven/>不起作用了。
解决办法:
1、删除beanDefines.xml的<context:component-scan base-package="com" />和<task:annotation-driven/>;
2、springMVC.xml添加配置<task:annotation-driven/>。