0

如何关闭 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping detectHandlers ,我将 spring 3 启动置于调试模式,我看到所有类都调用 'detectHandlers'

例子

[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping detectHandlers org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:86)] - Rejected bean name 'org.springframework.security.authenticationManager': no URL paths identified

[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping detectHandlers org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:86)] - Rejected bean name 'systemProperties': no URL paths identified

[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping detectHandlers org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:86)] - Rejected bean name 'systemEnvironment': no URL paths identified

只有我的“控制器”类有处理程序,而所有其他类都没有。我正在尝试加快春季启动。无论如何要为每个班级关闭此自动检测处理程序功能?

4

2 回答 2

1

“只有我的“控制器”类有处理程序,所有其他类都没有”

你说的对。为了知道一个类是否是一个控制器,Spring 必须检查它。这正是您在这里看到的:Spring 正在寻找类型级别的存在@Controller@RequestMapping类型。

于 2013-07-09T06:11:36.530 回答
1

您可以使用过滤器跳过不必要的课程:

<beans>

   <context:component-scan base-package="org.example">
      <context:exclude-filter type="regex" expression=".*NotControllerBean"/>
   </context:component-scan>

</beans>

对我来说最高效和最清晰的解决方案是将控制器移动到专用包并仅使用此包进行组件扫描。

于 2013-07-09T10:47:36.403 回答