Package org.springframework.boot.builder
Class SpringApplicationBuilder
java.lang.Object
org.springframework.boot.builder.SpringApplicationBuilder
Builder for
SpringApplication and ApplicationContext instances with
convenient fluent API and context hierarchy support. Simple example of a context
hierarchy:
new SpringApplicationBuilder(ParentConfig.class).child(ChildConfig.class).run(args);Another common use case is setting active profiles and default properties to set up the environment for an application:
new SpringApplicationBuilder(Application.class).profiles("server")
.properties("transport=local").run(args);
If your needs are simpler, consider using the static convenience methods in SpringApplication instead.
- Since:
- 1.0.0
- Author:
- Dave Syer, Andy Wilkinson
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSpringApplicationBuilder(Class<?>... sources) SpringApplicationBuilder(ResourceLoader resourceLoader, Class<?>... sources) -
Method Summary
Modifier and TypeMethodDescriptionaddBootstrapRegistryInitializer(BootstrapRegistryInitializer bootstrapRegistryInitializer) AddsBootstrapRegistryInitializerinstances that can be used to initialize theBootstrapRegistry.addCommandLineProperties(boolean addCommandLineProperties) Flag to indicate that command line arguments should be added to the environment.allowCircularReferences(boolean allowCircularReferences) Whether to allow circular references between beans and automatically try to resolve them.Accessor for the current application.applicationStartup(ApplicationStartup applicationStartup) Configure theApplicationStartupto be used with theApplicationContextfor collecting startup metrics.Sets theBannerinstance which will be used to print the banner when no static banner file is provided.bannerMode(Banner.Mode bannerMode) beanNameGenerator(BeanNameGenerator beanNameGenerator) Bean name generator for automatically generated bean names in the application context.build()Returns a fully configuredSpringApplicationthat is ready to run.Returns a fully configuredSpringApplicationthat is ready to run.Create a child application with the provided sources.context()Accessor for the current application context.contextFactory(ApplicationContextFactory factory) Explicitly set the factory used to create the application context.protected SpringApplicationcreateSpringApplication(ResourceLoader resourceLoader, Class<?>... sources) Creates a newSpringApplicationinstance from the given sources using the givenResourceLoader.environment(ConfigurableEnvironment environment) Environment for the application context.environmentPrefix(String environmentPrefix) Prefix that should be applied when obtaining configuration properties from the system environment.headless(boolean headless) Sets if the application is headless and should not instantiate AWT.initializers(ApplicationContextInitializer<?>... initializers) Add some initializers to the application (applied to theApplicationContextbefore any bean definitions are loaded).lazyInitialization(boolean lazyInitialization) Flag to control whether the application should be initialized lazily.listeners(ApplicationListener<?>... listeners) Add some listeners to the application (listening for SpringApplication events as well as regular Spring events once the context is running).logStartupInfo(boolean logStartupInfo) Flag to indicate the startup information should be logged.Fixes the main application class that is used to anchor the startup messages.Add a parent application with the provided sources.parent(ConfigurableApplicationContext parent) Add an already running parent context to an existing application.Add to the active Spring profiles for this app (and its parent and children).