在测试SpringMvc时出现空指针异常
多半是配置的问题
在 context:component-scan 的子标签中 exclude 和include 两个是相反的意思
<context:component-scan base-package="xxxx">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
在这里出错就是把扫描变成了不扫描 多多注意这些配置细节。
注意use-default-filters="false"这个属性:默认为true,会扫描到@Service与@Reposity等,所以配置成false,只扫描需要的中的bean注解