问题背景:
在springmvc配置文件中扫描实体类 不能再service层注入 提示错误 NoClassDefFoundError
原因
springmvc是spring容器的一个子容器
在springmvc容器中可以调用spring容器实体类,而在spring容器中不能注入使用springmvc扫描的实体类
简单来讲 controller可以注入service service不能注入controller
我的问题是在部署中间件rocketmq将扫描配置放到了springmvc配置文件中 导致service不能注入rocketmq实体类
springmvc.xml1
2
3
4
5<!-- 自动扫描且只扫描@Controller -->
<context:component-scan base-package="com.csdn.uc.controller" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" />
</context:component-scan>
spring.xml
1 |
|