如何打开Spring的组件扫描调试信息?

hap*_*dha 11 debugging logging spring-mvc

我试图找出我正在维护,使用的应用程序的数据库表的数量.我在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" />
Run Code Online (Sandbox Code Playgroud)

还有其他与该项目相关的子项目,@Entity并且@Repository已经广泛使用.我想如果我能够以某种方式打开Spring的调试,它将列出所有类名,并且当它基于基础包扫描它们时,我应该能够找到所有jpa存储库.如何打开弹簧调试以吐出这些信息?

这就是我在log4j.properties中的内容:

log4j.rootLogger=error, file
log4j.category.org.hibernate=debug, hb
log4j.category.org.springframework=debug, spring
Run Code Online (Sandbox Code Playgroud)

mom*_*bip 18

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

<logger name="org.springframework.core.io.support" level="debug"/> <logger name="org.springframework.context.annotation" level="debug"/>

  • 默认情况下(web-starter)Spring 使用 Logback,因此应将其放入 logback.xml 文件中。 (2认同)

Sot*_*lis 4

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