在springservlet .xml中:
<context:component-scan base-package="net.controller" />
(我假设服务impl与服务接口“ net.service”位于同一程序包中)
我认为您必须将包net.service(或全部net)添加到组件扫描中。当前,spring仅在net.controller中搜索组件,并且由于您的服务隐含在net.service中,因此Spring不会实例化它。

在springservlet .xml中:
<context:component-scan base-package="net.controller" />
(我假设服务impl与服务接口“ net.service”位于同一程序包中)
我认为您必须将包net.service(或全部net)添加到组件扫描中。当前,spring仅在net.controller中搜索组件,并且由于您的服务隐含在net.service中,因此Spring不会实例化它。
上一篇 Spring MVC无需请求即可在WEB-INF下获取文件
下一篇 Spring-ApplicationContext registerBean自动装配失败,但getBean在Spring 5中工作