Java 类org.springframework.boot.autoconfigure.EnableAutoConfiguration 实例源码

项目:morphia-spring-boot-starter    文件:MorphiaUtils.java   
/**
 * Return root package of spring boot application.
 *
 * @param applicationContext
 * @return list of packages
 */
public static List<String> getApplicationPackageName(final ApplicationContext applicationContext) {

    Set<String> candidateClasses = new HashSet<>();
    candidateClasses.addAll(Arrays.asList(applicationContext.getBeanNamesForAnnotation(SpringBootApplication.class)));
    candidateClasses.addAll(Arrays.asList(applicationContext.getBeanNamesForAnnotation(EnableAutoConfiguration.class)));
    candidateClasses.addAll(Arrays.asList(applicationContext.getBeanNamesForAnnotation(ComponentScan.class)));

    if (candidateClasses.isEmpty()) {
        throw new RuntimeException("Is mandatory for the starter have @SpringBootApplication, @EnableAutoConfiguration or @ComponentScan annotation");
    } else {
        return candidateClasses.parallelStream()
                .map(candidateClazz -> applicationContext.getBean(candidateClazz).getClass().getPackage().getName())
                .distinct()
                .collect(Collectors.toList());
    }

}
项目:initializr    文件:ProjectGeneratorTests.java   
@Test
public void springBootUseSpringBootApplicationGroovy() {
    ProjectRequest request = createProjectRequest("web");
    request.setLanguage("groovy");
    request.setBootVersion("1.2.0.RC1");
    request.setName("MyDemo");
    request.setPackageName("foo");
    generateProject(request)
            .sourceCodeAssert("src/main/groovy/foo/MyDemoApplication.groovy")
            .hasImports(SpringBootApplication.class.getName())
            .doesNotHaveImports(EnableAutoConfiguration.class.getName(),
                    ComponentScan.class.getName(), Configuration.class.getName())
            .contains("@SpringBootApplication").doesNotContain(
                    "@EnableAutoConfiguration", "@Configuration", "@ComponentScan");
}
项目:springboot-analysis    文件:LoadTest.java   
@Test
public void test02() {
    List<String> classes = SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, this.getClass().getClassLoader());
    classes.forEach(clazz -> {
        System.out.println("==== " + clazz);
    });
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:BootGlobalAuthenticationConfiguration.java   
@Override
public void init(AuthenticationManagerBuilder auth) {
    Map<String, Object> beansWithAnnotation = this.context
            .getBeansWithAnnotation(EnableAutoConfiguration.class);
    if (logger.isDebugEnabled()) {
        logger.debug("Eagerly initializing " + beansWithAnnotation);
    }
}
项目:spring-boot-concourse    文件:BootGlobalAuthenticationConfiguration.java   
@Override
public void init(AuthenticationManagerBuilder auth) {
    Map<String, Object> beansWithAnnotation = this.context
            .getBeansWithAnnotation(EnableAutoConfiguration.class);
    if (logger.isDebugEnabled()) {
        logger.debug("Eagerly initializing " + beansWithAnnotation);
    }
}
项目:contestparser    文件:BootGlobalAuthenticationConfiguration.java   
@Override
public void init(AuthenticationManagerBuilder auth) {
    Map<String, Object> beansWithAnnotation = this.context
            .getBeansWithAnnotation(EnableAutoConfiguration.class);
    if (logger.isDebugEnabled()) {
        logger.debug("Eagerly initializing " + beansWithAnnotation);
    }
}
项目:initializr    文件:ProjectGeneratorTests.java   
@Test
public void springBoot11UseEnableAutoConfigurationJava() {
    ProjectRequest request = createProjectRequest("web");
    request.setBootVersion("1.1.9.RELEASE");
    request.setName("MyDemo");
    request.setPackageName("foo");
    generateProject(request)
            .sourceCodeAssert("src/main/java/foo/MyDemoApplication.java")
            .hasImports(EnableAutoConfiguration.class.getName(),
                    ComponentScan.class.getName(), Configuration.class.getName())
            .doesNotHaveImports(SpringBootApplication.class.getName())
            .contains("@EnableAutoConfiguration", "@Configuration", "@ComponentScan")
            .doesNotContain("@SpringBootApplication");
}
项目:initializr    文件:ProjectGeneratorTests.java   
@Test
public void springBootUseSpringBootApplicationJava() {
    ProjectRequest request = createProjectRequest("web");
    request.setBootVersion("1.2.0.RC1");
    request.setName("MyDemo");
    request.setPackageName("foo");
    generateProject(request)
            .sourceCodeAssert("src/main/java/foo/MyDemoApplication.java")
            .hasImports(SpringBootApplication.class.getName())
            .doesNotHaveImports(EnableAutoConfiguration.class.getName(),
                    ComponentScan.class.getName(), Configuration.class.getName())
            .contains("@SpringBootApplication").doesNotContain(
                    "@EnableAutoConfiguration", "@Configuration", "@ComponentScan");
}
项目:initializr    文件:ProjectGeneratorTests.java   
@Test
public void springBoot11UseEnableAutoConfigurationGroovy() {
    ProjectRequest request = createProjectRequest("web");
    request.setLanguage("groovy");
    request.setBootVersion("1.1.9.RELEASE");
    request.setName("MyDemo");
    request.setPackageName("foo");
    generateProject(request)
            .sourceCodeAssert("src/main/groovy/foo/MyDemoApplication.groovy")
            .hasImports(EnableAutoConfiguration.class.getName(),
                    ComponentScan.class.getName(), Configuration.class.getName())
            .doesNotHaveImports(SpringBootApplication.class.getName())
            .contains("@EnableAutoConfiguration", "@Configuration", "@ComponentScan")
            .doesNotContain("@SpringBootApplication");
}
项目:initializr    文件:ProjectGeneratorTests.java   
@Test
public void springBoot11UseEnableAutoConfigurationKotlin() {
    ProjectRequest request = createProjectRequest("web");
    request.setLanguage("kotlin");
    request.setBootVersion("1.1.9.RELEASE");
    request.setName("MyDemo");
    request.setPackageName("foo");
    generateProject(request)
            .sourceCodeAssert("src/main/kotlin/foo/MyDemoApplication.kt")
            .hasImports(EnableAutoConfiguration.class.getName(),
                    ComponentScan.class.getName(), Configuration.class.getName())
            .doesNotHaveImports(SpringBootApplication.class.getName())
            .contains("@EnableAutoConfiguration", "@Configuration", "@ComponentScan")
            .doesNotContain("@SpringBootApplication");
}
项目:initializr    文件:ProjectGeneratorTests.java   
@Test
public void springBootUseSpringBootApplicationKotlin() {
    ProjectRequest request = createProjectRequest("web");
    request.setLanguage("kotlin");
    request.setBootVersion("1.2.0.RC1");
    request.setName("MyDemo");
    request.setPackageName("foo");
    generateProject(request)
            .sourceCodeAssert("src/main/kotlin/foo/MyDemoApplication.kt")
            .hasImports(SpringBootApplication.class.getName())
            .doesNotHaveImports(EnableAutoConfiguration.class.getName(),
                    ComponentScan.class.getName(), Configuration.class.getName())
            .contains("@SpringBootApplication").doesNotContain(
                    "@EnableAutoConfiguration", "@Configuration", "@ComponentScan");
}
项目:butterfly    文件:AnnotatedWithTest.java   
@Test
public void fqdnTest() throws ParseException {
    AnnotatedWith annotatedWith = new AnnotatedWith(EnableAutoConfiguration.class);
    Assert.assertTrue(annotatedWith.evaluate(compilationUnit));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OverrideAutoConfigurationContextCustomizerFactory.java   
@Override
public void customizeContext(ConfigurableApplicationContext context,
        MergedContextConfiguration mergedConfig) {
    EnvironmentTestUtils.addEnvironment(context,
            EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY + "=false");
}
项目:spring-boot-concourse    文件:OverrideAutoConfigurationContextCustomizerFactory.java   
@Override
public void customizeContext(ConfigurableApplicationContext context,
        MergedContextConfiguration mergedConfig) {
    EnvironmentTestUtils.addEnvironment(context,
            EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY + "=false");
}
项目:onetwo    文件:SpringFactoriesLoaderTest.java   
@Test
public void test(){
    List<String> names = SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, ClassUtils.getDefaultClassLoader());
    System.out.println("names:"+names);
}