问题:Spring单元测试 报错 Error creating bean with name
原因:Spring和SpringMVC扫描注解类的冲突问题
解决:
<!-- 扫描Controller -->
<context:component-scan base-package="com.hi8.oss.web">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
让 spring-view-mvc.xml 只管理Controller
在spring-application-context.xml 扫描中排除Controller
<!-- 自动扫描 -->
<context:component-scan base-package="com.hi8.oss">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
单元测试通过
参考博文
http://blog.csdn.net/xiaobao5214/article/details/52042041