Java Code Examples for org.springframework.boot.autoconfigure.EnableAutoConfiguration

The following are top voted examples for showing how to use org.springframework.boot.autoconfigure.EnableAutoConfiguration. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: morphia-spring-boot-starter   File: MorphiaUtils.java   View source code 6 votes vote down vote up
/**
 * 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());
    }

}
 
Example 2
Project: initializr   File: ProjectGeneratorTests.java   View source code 6 votes vote down vote up
@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");
}
 
Example 3
Project: springboot-analysis   File: LoadTest.java   View source code 5 votes vote down vote up
@Test
public void test02() {
    List<String> classes = SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, this.getClass().getClassLoader());
    classes.forEach(clazz -> {
        System.out.println("==== " + clazz);
    });
}
 
Example 4
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: BootGlobalAuthenticationConfiguration.java   View source code 5 votes vote down vote up
@Override
public void init(AuthenticationManagerBuilder auth) {
	Map<String, Object> beansWithAnnotation = this.context
			.getBeansWithAnnotation(EnableAutoConfiguration.class);
	if (logger.isDebugEnabled()) {
		logger.debug("Eagerly initializing " + beansWithAnnotation);
	}
}
 
Example 5
Project: spring-boot-concourse   File: BootGlobalAuthenticationConfiguration.java   View source code 5 votes vote down vote up
@Override
public void init(AuthenticationManagerBuilder auth) {
	Map<String, Object> beansWithAnnotation = this.context
			.getBeansWithAnnotation(EnableAutoConfiguration.class);
	if (logger.isDebugEnabled()) {
		logger.debug("Eagerly initializing " + beansWithAnnotation);
	}
}
 
Example 6
Project: contestparser   File: BootGlobalAuthenticationConfiguration.java   View source code 5 votes vote down vote up
@Override
public void init(AuthenticationManagerBuilder auth) {
	Map<String, Object> beansWithAnnotation = this.context
			.getBeansWithAnnotation(EnableAutoConfiguration.class);
	if (logger.isDebugEnabled()) {
		logger.debug("Eagerly initializing " + beansWithAnnotation);
	}
}
 
Example 7
Project: initializr   File: ProjectGeneratorTests.java   View source code 5 votes vote down vote up
@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");
}
 
Example 8
Project: initializr   File: ProjectGeneratorTests.java   View source code 5 votes vote down vote up
@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");
}
 
Example 9
Project: initializr   File: ProjectGeneratorTests.java   View source code 5 votes vote down vote up
@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");
}
 
Example 10
Project: initializr   File: ProjectGeneratorTests.java   View source code 5 votes vote down vote up
@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");
}
 
Example 11
Project: initializr   File: ProjectGeneratorTests.java   View source code 5 votes vote down vote up
@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");
}
 
Example 12
Project: butterfly   File: AnnotatedWithTest.java   View source code 4 votes vote down vote up
@Test
public void fqdnTest() throws ParseException {
    AnnotatedWith annotatedWith = new AnnotatedWith(EnableAutoConfiguration.class);
    Assert.assertTrue(annotatedWith.evaluate(compilationUnit));
}
 
Example 13
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: OverrideAutoConfigurationContextCustomizerFactory.java   View source code 4 votes vote down vote up
@Override
public void customizeContext(ConfigurableApplicationContext context,
		MergedContextConfiguration mergedConfig) {
	EnvironmentTestUtils.addEnvironment(context,
			EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY + "=false");
}
 
Example 14
Project: spring-boot-concourse   File: OverrideAutoConfigurationContextCustomizerFactory.java   View source code 4 votes vote down vote up
@Override
public void customizeContext(ConfigurableApplicationContext context,
		MergedContextConfiguration mergedConfig) {
	EnvironmentTestUtils.addEnvironment(context,
			EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY + "=false");
}
 
Example 15
Project: onetwo   File: SpringFactoriesLoaderTest.java   View source code 4 votes vote down vote up
@Test
public void test(){
	List<String> names = SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, ClassUtils.getDefaultClassLoader());
	System.out.println("names:"+names);
}