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.

Author

Dave Syer

Andy Wilkinson

Since

1.0.0

See also

Constructors

Link copied to clipboard
constructor(sources: Array<Class<out Any>>)
constructor(resourceLoader: ResourceLoader, sources: Array<Class<out Any>>)

Functions

Link copied to clipboard
Adds BootstrapRegistryInitializer instances that can be used to initialize the BootstrapRegistry.
Link copied to clipboard
open fun addCommandLineProperties(addCommandLineProperties: Boolean): SpringApplicationBuilder
Flag to indicate that command line arguments should be added to the environment.
Link copied to clipboard
open fun allowCircularReferences(allowCircularReferences: Boolean): SpringApplicationBuilder
Whether to allow circular references between beans and automatically try to resolve them.
Link copied to clipboard
Accessor for the current application.
Link copied to clipboard
Configure the ApplicationStartup to be used with the ApplicationContext for collecting startup metrics.
Link copied to clipboard
Sets the Banner instance which will be used to print the banner when no static banner file is provided.
Link copied to clipboard
Link copied to clipboard
Bean name generator for automatically generated bean names in the application context.
Link copied to clipboard
Returns a fully configured SpringApplication that is ready to run.
Link copied to clipboard
open fun child(sources: Array<Class<out Any>>): SpringApplicationBuilder
Create a child application with the provided sources.
Link copied to clipboard
Accessor for the current application context.
Link copied to clipboard
Explicitly set the factory used to create the application context.
Link copied to clipboard
Environment for the application context.
Link copied to clipboard
open fun environmentPrefix(environmentPrefix: String): SpringApplicationBuilder
Prefix that should be applied when obtaining configuration properties from the system environment.
Link copied to clipboard
Sets if the application is headless and should not instantiate AWT.
Link copied to clipboard
Add some initializers to the application (applied to the ApplicationContext before any bean definitions are loaded).
Link copied to clipboard
open fun lazyInitialization(lazyInitialization: Boolean): SpringApplicationBuilder
Flag to control whether the application should be initialized lazily.
Link copied to clipboard
Add some listeners to the application (listening for SpringApplication events as well as regular Spring events once the context is running).
Link copied to clipboard
Flag to indicate the startup information should be logged.
Link copied to clipboard
open fun main(mainApplicationClass: Class<out Any>): SpringApplicationBuilder
Fixes the main application class that is used to anchor the startup messages.
Link copied to clipboard
open fun parent(sources: Array<Class<out Any>>): SpringApplicationBuilder
Add a parent application with the provided sources.
Add an already running parent context to an existing application.
Link copied to clipboard
Add to the active Spring profiles for this app (and its parent and children).
Link copied to clipboard
open fun properties(defaultProperties: Array<String>): SpringApplicationBuilder
Default properties for the environment in the form key=value or key:value.
Default properties for the environment.
open fun properties(defaultProperties: Properties): SpringApplicationBuilder
Default properties for the environment.Multiple calls to this method are cumulative and will not clear any previously set properties.
Link copied to clipboard
open fun registerShutdownHook(registerShutdownHook: Boolean): SpringApplicationBuilder
Sets if the created ApplicationContext should have a shutdown hook registered.
Link copied to clipboard
ResourceLoader for the application context.
Link copied to clipboard
Create an application context (and its parent if specified) with the command line args provided.
Link copied to clipboard
Flag to indicate if the ApplicationConversionService should be added to the application context's Environment.
Link copied to clipboard
open fun sibling(sources: Array<Class<out Any>>): SpringApplicationBuilder
open fun sibling(sources: Array<Class<out Any>>, args: Array<String>): SpringApplicationBuilder
Create a sibling application (one with the same parent).
Link copied to clipboard
open fun sources(sources: Array<Class<out Any>>): SpringApplicationBuilder
Add more sources (configuration classes and components) to this application.
Link copied to clipboard
open fun web(webApplicationType: WebApplicationType): SpringApplicationBuilder
Flag to explicitly request a specific type of web application.