diff --git a/spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java b/spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java index 5c0f1ee147..4d3836341a 100644 --- a/spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java +++ b/spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java @@ -47,8 +47,6 @@ import org.springframework.core.env.SimpleCommandLinePropertySource; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.support.SpringFactoriesLoader; -import org.springframework.core.type.StandardAnnotationMetadata; -import org.springframework.stereotype.Component; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.web.context.ConfigurableWebApplicationContext; @@ -565,23 +563,4 @@ public class SpringApplication { return new SpringApplication(sources).run(args); } - /** - * Static helper that can be used to run a {@link SpringApplication} from the - * specified {@code @Component} sources. Any class not annotated or meta-annotated - * with {@code @Component} will be ignored. - * @param classes the source classes to consider loading - * @param args the application arguments (usually passed from a Java main method) - * @return the running {@link ApplicationContext} - */ - public static ApplicationContext runComponents(Class[] classes, String... args) { - List> componentClasses = new ArrayList>(); - for (Class candidate : classes) { - StandardAnnotationMetadata metadata = new StandardAnnotationMetadata( - candidate); - if (metadata.isAnnotated(Component.class.getName())) { - componentClasses.add(candidate); - } - } - return new SpringApplication(componentClasses.toArray()).run(args); - } } diff --git a/spring-bootstrap/src/test/java/org/springframework/bootstrap/SpringApplicationTests.java b/spring-bootstrap/src/test/java/org/springframework/bootstrap/SpringApplicationTests.java index 84bc487703..7ea645e691 100644 --- a/spring-bootstrap/src/test/java/org/springframework/bootstrap/SpringApplicationTests.java +++ b/spring-bootstrap/src/test/java/org/springframework/bootstrap/SpringApplicationTests.java @@ -274,8 +274,8 @@ public class SpringApplicationTests { @Test public void runComponents() throws Exception { - this.context = SpringApplication.runComponents(new Class[] { - ExampleWebConfig.class, Object.class }); + this.context = SpringApplication.run(new Object[] { ExampleWebConfig.class, + Object.class }, new String[0]); assertNotNull(this.context); }