List of usage examples for org.springframework.boot SpringApplication SpringApplication
public SpringApplication(Class<?>... primarySources)
From source file:org.springframework.boot.SpringApplication.java
/** * Static helper that can be used to run a {@link SpringApplication} from the * specified sources using default settings and user supplied arguments. * @param sources the sources to load/*from w w w . j ava2s .c o m*/ * @param args the application arguments (usually passed from a Java main method) * @return the running {@link ApplicationContext} */ public static ConfigurableApplicationContext run(Object[] sources, String[] args) { return new SpringApplication(sources).run(args); }
From source file:org.springframework.boot.web.SpringServletInitializer.java
protected WebApplicationContext createRootApplicationContext(ServletContext servletContext) { ApplicationContext parent = null;//from www . ja v a 2s. c om Object object = servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (object instanceof ApplicationContext) { this.logger.info("Root context already created (using as parent)."); parent = (ApplicationContext) object; servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, null); } SpringApplication application = new SpringApplication((Object[]) getConfigClasses()); AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext(); context.setParent(parent); context.setServletContext(servletContext); application.setApplicationContext(context); return (WebApplicationContext) application.run(); }