org.springframework.boot.autoconfigure.EnableAutoConfiguration Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.EnableAutoConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultAutoConfigurationImportListener.java    From thinking-in-spring-boot-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onAutoConfigurationImportEvent(AutoConfigurationImportEvent event) {
    // 获取当前 ClassLoader
    ClassLoader classLoader = event.getClass().getClassLoader();
    // 候选的自动装配类名单
    List<String> candidates =
            SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, classLoader);
    // 实际的自动装配类名单
    List<String> configurations = event.getCandidateConfigurations();
    // 排除的自动装配类名单
    Set<String> exclusions = event.getExclusions();
    // 输出各自数量
    System.out.printf("自动装配类名单 - 候选数量:%d,实际数量:%d,排除数量:%s\n",
            candidates.size(), configurations.size(), exclusions.size());
    // 输出实际和排除的自动装配类名单
    System.out.println("实际的自动装配类名单:");
    event.getCandidateConfigurations().forEach(System.out::println);
    System.out.println("排除的自动装配类名单:");
    event.getExclusions().forEach(System.out::println);
}
 
Example #2
Source File: FunctionalInstallerImportRegistrars.java    From spring-init with Apache License 2.0 5 votes vote down vote up
@Override
public void add(Class<?> importer, String typeName) {
	if (typeName.endsWith(".xml")) {
		this.registrars.add(new Imported(importer, typeName, context));
	}
	else {
		if (isAutoConfiguration(importer, typeName) && !context.getEnvironment()
				.getProperty(EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY, Boolean.class, true)) {
			return;
		}
		this.registrars.add(new Imported(importer, typeName, context.getClassLoader()));
	}
}
 
Example #3
Source File: AnnotatedWithTest.java    From butterfly with MIT License 4 votes vote down vote up
@Test
public void fqdnTest() throws ParseException {
    AnnotatedWith annotatedWith = new AnnotatedWith(EnableAutoConfiguration.class);
    Assert.assertTrue(annotatedWith.evaluate(compilationUnit));
}
 
Example #4
Source File: SpringFactoriesLoaderTest.java    From onetwo with Apache License 2.0 4 votes vote down vote up
@Test
public void test(){
	List<String> names = SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, ClassUtils.getDefaultClassLoader());
	System.out.println("names:"+names);
}