在Spring的配置文件applicationContext.xml中
<!-- 自动扫描与装配bean -->
<context:component-scan base-package="cn.itcast.oa"></context:component-scan>
当运行tomcat时出现错误
Caused by: java.lang.IllegalStateException: Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
spring的版本太低了,tomcat的配置中更换一个低版本的jdk,解决问题。