Debugging 如何打开Spring';组件扫描调试信息?
我试图找出我维护的应用程序使用的数据库表的数量。我的appContext.xml中有这个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
<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文件中。