Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging 如何打开Spring';组件扫描调试信息?_Debugging_Spring Mvc_Logging - Fatal编程技术网

Debugging 如何打开Spring';组件扫描调试信息?

Debugging 如何打开Spring';组件扫描调试信息?,debugging,spring-mvc,logging,Debugging,Spring Mvc,Logging,我试图找出我维护的应用程序使用的数据库表的数量。我的appContext.xml中有这个 <context:component-scan base-package="com.foo, com.bar" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" /> <cont

我试图找出我维护的应用程序使用的数据库表的数量。我的appContext.xml中有这个

 <context:component-scan base-package="com.foo, com.bar" use-default-filters="false">
 <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
 <context:include-filter type="annotation" expression="org.springframework.stereotype.Component" />
 <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
 </context:component-scan>
         ....
 <jpa:repositories base-package="com.foo.abc, com.bar.def" />

处理存储库注册的类是
org.springframework.data.repository.config.RepositoryConfigurationDelegate
。您需要将
rootLogger
级别设置为调试,或者将log4j配置为具有
org.springframework.data.repository.config.RepositoryConfigurationDelegate
或其任何具有日志级别调试的父级记录器。

这是一个有点老的主题,但我找到了适合我的解决方案(Spring 4.1.7):


为以下对象启用调试级别日志记录:

  • 组件扫描报告的
    org.springframework.context.annotation
  • 例如:

    2021-05-01 02:58:51.553 [Test worker] [DEBUG] o.s.c.a.ClassPathBeanDefinitionScanner - Identified candidate component class: file [/absolute/path/to/TestController.class]
    
    ErrorMvcAutoConfiguration matched:
          - @ConditionalOnClass found required classes 'javax.servlet.Servlet', 'org.springframework.web.servlet.DispatcherServlet' (OnClassCondition)
          - found 'session' scope (OnWebApplicationCondition)
    
  • 自动配置报告的
    org.springframework.boot.autoconfigure.logging
  • 例如:

    2021-05-01 02:58:51.553 [Test worker] [DEBUG] o.s.c.a.ClassPathBeanDefinitionScanner - Identified candidate component class: file [/absolute/path/to/TestController.class]
    
    ErrorMvcAutoConfiguration matched:
          - @ConditionalOnClass found required classes 'javax.servlet.Servlet', 'org.springframework.web.servlet.DispatcherServlet' (OnClassCondition)
          - found 'session' scope (OnWebApplicationCondition)
    
    默认情况下(WebStarter)Spring使用Logback,因此应该将其放在Logback.xml文件中。