本文整理匯總了Java中org.springframework.boot.autoconfigure.SpringBootApplication類的典型用法代碼示例。如果您正苦於以下問題:Java SpringBootApplication類的具體用法?Java SpringBootApplication怎麽用?Java SpringBootApplication使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SpringBootApplication類屬於org.springframework.boot.autoconfigure包,在下文中一共展示了SpringBootApplication類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: assertExistsPrivateCtor
import org.springframework.boot.autoconfigure.SpringBootApplication; //導入依賴的package包/類
@Test
public void assertExistsPrivateCtor() {
reflections.getSubTypesOf(Object.class).stream()
.filter(clazz -> !clazz.isAnnotationPresent(Configuration.class))
.filter(clazz -> !clazz.isAnnotationPresent(Component.class))
.filter(clazz -> !clazz.isAnnotationPresent(SpringBootApplication.class))
.filter(clazz -> !clazz.getName().endsWith("Test"))
.filter(clazz -> !clazz.isInterface())
.filter(clazz ->
Arrays.stream(clazz.getDeclaredFields())
.allMatch(field -> Modifier.isStatic(field.getModifiers())))
.forEach(clazz -> {
System.out.println("Expecting class "+clazz.getName()+" to :");
System.out.print("\t-> be final ");
assertThat(clazz).isFinal();
System.out.println("[*]");
System.out.print("\t-> have exactly one constructor ");
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
assertThat(constructors).hasSize(1);
System.out.println("[*]");
System.out.print("\t-> and that this constructor is private ");
assertThat(Modifier.isPrivate(constructors[0].getModifiers()));
System.out.println("[*]");
});
}
示例2: getApplicationPackageName
import org.springframework.boot.autoconfigure.SpringBootApplication; //導入依賴的package包/類
/**
* 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());
}
}
示例3: springBootUseSpringBootApplicationGroovy
import org.springframework.boot.autoconfigure.SpringBootApplication; //導入依賴的package包/類
@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");
}
示例4:
import org.springframework.boot.autoconfigure.SpringBootApplication; //導入依賴的package包/類
@Bean
@ConditionalOnClass(SpringBootApplication.class)
public FilterRegistrationBean keycloakPreAuthActionsFilterRegistrationBean(
KeycloakPreAuthActionsFilter filter) {
FilterRegistrationBean registrationBean = new FilterRegistrationBean(filter);
registrationBean.setEnabled(false);
return registrationBean;
}
示例5: springBoot11UseEnableAutoConfigurationJava
import org.springframework.boot.autoconfigure.SpringBootApplication; //導入依賴的package包/類
@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");
}
示例6: springBootUseSpringBootApplicationJava
import org.springframework.boot.autoconfigure.SpringBootApplication; //導入依賴的package包/類
@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");
}
示例7: springBoot11UseEnableAutoConfigurationGroovy
import org.springframework.boot.autoconfigure.SpringBootApplication; //導入依賴的package包/類
@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");
}
示例8: springBoot11UseEnableAutoConfigurationKotlin
import org.springframework.boot.autoconfigure.SpringBootApplication; //導入依賴的package包/類
@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");
}
示例9: springBootUseSpringBootApplicationKotlin
import org.springframework.boot.autoconfigure.SpringBootApplication; //導入依賴的package包/類
@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");
}