如何获取应用的Spring Boot(自动或非自动)配置列表?
答案 0 :(得分:5)
构建完工件后,如果启动它,可以获得自动配置报告,包括--debug
命令参数:
java -jar artifact.jar --debug
或直接将其添加为SpringApplication.run()
的参数SpringApplication.run(WebApp.class, "--debug");
或在IDE内部,在启动配置中添加--debug
作为参数。
报告将如下所示:
=========================
AUTO-CONFIGURATION REPORT
=========================
Positive matches:
-----------------
AopAutoConfiguration
- @ConditionalOnClass classes found: org.springframework.context.annotation.EnableAspectJAutoProxy,org.aspectj.lang.annotation.Aspect,org.aspectj.lang.reflect.Advice (OnClassCondition)
- matched (OnPropertyCondition)
AopAutoConfiguration.JdkDynamicAutoProxyConfiguration
- matched (OnPropertyCondition)
AuditAutoConfiguration#authenticationAuditListener
- @ConditionalOnClass classes found: org.springframework.security.authentication.event.AbstractAuthenticationEvent (OnClassCondition)
AuditAutoConfiguration#authorizationAuditListener
- @ConditionalOnClass classes found: org.springframework.security.access.event.AbstractAuthorizationEvent (OnClassCondition)
AuditAutoConfiguration.AuditEventRepositoryConfiguration
- @ConditionalOnMissingBean (types: org.springframework.boot.actuate.audit.AuditEventRepository; SearchStrategy: all) found no beans (OnBeanCondition)
[...]
Negative matches:
-----------------
ActiveMQAutoConfiguration
- required @ConditionalOnClass classes not found: javax.jms.ConnectionFactory,org.apache.activemq.ActiveMQConnectionFactory (OnClassCondition)
AopAutoConfiguration.CglibAutoProxyConfiguration
- @ConditionalOnProperty missing required properties spring.aop.proxy-target-class (OnPropertyCondition)
AtomikosJtaConfiguration
- required @ConditionalOnClass classes not found: com.atomikos.icatch.jta.UserTransactionManager (OnClassCondition)
答案 1 :(得分:0)
Spring Boot Actuator能够转储此类信息。
启用执行器,然后打开http://localhost/configprops。 以下是我的一个项目中的示例:
Actuator显示了很多有用的信息(autoconfig,env,映射,bean,日志文件,跟踪等),所以我建议你甚至在生产机器上启用它。它可以很容易地通过密码保护。
要查看来自application.properties / application.yml的配置,您可以使用/env
端点。