Java 如何启用Spring';测试中的自动配置报告?
我刚刚发现Spring有一个调试模式,它提供了关于自动配置的见解。对于服务器,可以通过将Java 如何启用Spring';测试中的自动配置报告?,java,spring,spring-boot,Java,Spring,Spring Boot,我刚刚发现Spring有一个调试模式,它提供了关于自动配置的见解。对于服务器,可以通过将--debug作为应用程序参数传递来启用它 是否有一种方法可以为测试(使用SpringJUnit4ClassRunner执行)启用调试模式? 如果自动配置报告正在工作,它应该打印一些输出,如下所示: ========================= AUTO-CONFIGURATION REPORT ========================= Positive matches: -------
--debug
作为应用程序参数传递来启用它
是否有一种方法可以为测试(使用SpringJUnit4ClassRunner
执行)启用调试模式?
如果自动配置报告正在工作,它应该打印一些输出,如下所示:
=========================
AUTO-CONFIGURATION REPORT
=========================
Positive matches:
-----------------
ConfigServiceBootstrapConfiguration#configServicePropertySource matched
- matched (OnPropertyCondition)
ConfigurationPropertiesRebinderAutoConfiguration matched
- @ConditionalOnBean (types: org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor; SearchStrategy: all) found the following [org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor] (OnBeanCondition)
ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesBeans matched
- @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesBeans; SearchStrategy: current) found no beans (OnBeanCondition)
ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesRebinder matched
- @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder; SearchStrategy: current) found no beans (OnBeanCondition)
EncryptionBootstrapConfiguration matched
- @ConditionalOnClass classes found: org.springframework.security.crypto.encrypt.TextEncryptor (OnClassCondition)
PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer matched
- @ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) found no beans (OnBeanCondition)
Negative matches:
-----------------
ConfigServiceBootstrapConfiguration.RetryConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.retry.annotation.Retryable,org.aspectj.lang.annotation.Aspect (OnClassCondition)
DiscoveryClientConfigServiceBootstrapConfiguration did not match
- @ConditionalOnProperty missing required properties spring.cloud.config.discovery.enabled (OnPropertyCondition)
EncryptionBootstrapConfiguration.RsaEncryptionConfiguration did not match
- @ConditionalOnClass classes found: org.springframework.security.rsa.crypto.RsaSecretEncryptor (OnClassCondition)
- Keystore nor key found in Environment (EncryptionBootstrapConfiguration.KeyCondition)
EncryptionBootstrapConfiguration.VanillaEncryptionConfiguration did not match
- required @ConditionalOnMissing classes found: org.springframework.security.rsa.crypto.RsaSecretEncryptor (OnClassCondition)
EurekaDiscoveryClientConfigServiceBootstrapConfiguration did not match
- @ConditionalOnClass classes found: org.springframework.cloud.config.client.ConfigServicePropertySourceLocator (OnClassCondition)
- @ConditionalOnProperty missing required properties spring.cloud.config.discovery.enabled (OnPropertyCondition)
Exclusions:
-----------
None
Unconditional classes:
----------------------
None
--debug
设置一个debug
属性,然后打开自动配置报告。例如,您可以在测试类上使用@TestPropertySource
在测试中执行相同的操作:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
@TestPropertySource(properties = "debug=true")
public class YourTests {
// …
}