Fluent Builder API
If you need to build an ApplicationContext hierarchy (multiple contexts with a parent/child relationship) or if you prefer using a “fluent” builder API, you can use the SpringApplicationBuilder.
The SpringApplicationBuilder lets you chain together multiple method calls and includes parent and child methods that let you create a hierarchy, as shown in the following example:
- 
Java 
- 
Kotlin 
		new SpringApplicationBuilder()
				.sources(Parent.class)
				.child(Application.class)
				.bannerMode(Banner.Mode.OFF)
				.run(args);		SpringApplicationBuilder()
			.sources(Parent::class.java)
			.child(Application::class.java)
			.bannerMode(Banner.Mode.OFF)
			.run(*args)| There are some restrictions when creating an ApplicationContexthierarchy.
For example, Web components must be contained within the child context, and the sameEnvironmentis used for both parent and child contexts.
See theSpringApplicationBuilderJavadoc for full details. |