Home / Function/ createRootApplicationContext() — spring-boot Function Reference

createRootApplicationContext() — spring-boot Function Reference

Architecture documentation for the createRootApplicationContext() function in SpringBootServletInitializer.java from the spring-boot codebase.

Function java GradlePlugin RunTasks calls 16 called by 1

Entity Profile

Dependency Diagram

graph TD
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5["createRootApplicationContext()"]
  551fddce_2746_09ab_3228_2134676216f4["onStartup()"]
  551fddce_2746_09ab_3228_2134676216f4 -->|calls| 6de23dd6_ba39_4c8b_2378_eb7c00e92ed5
  3ee29355_5440_31bc_45da_1fef0069235a["createSpringApplicationBuilder()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| 3ee29355_5440_31bc_45da_1fef0069235a
  9e7cf5ce_7930_7d71_bb71_2294ddf12882["getExistingRootWebApplicationContext()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| 9e7cf5ce_7930_7d71_bb71_2294ddf12882
  57e90fc9_a569_d0ca_8062_91b778ba32ea["getLogger()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| 57e90fc9_a569_d0ca_8062_91b778ba32ea
  9c963be5_6ca5_bdb2_a5cb_0da063b3eb42["initializers()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| 9c963be5_6ca5_bdb2_a5cb_0da063b3eb42
  d661f123_67d2_1aaf_091a_7734c416de34["ParentContextApplicationContextInitializer()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| d661f123_67d2_1aaf_091a_7734c416de34
  523ba120_07f3_22ae_4fed_37cde1756a41["contextFactory()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| 523ba120_07f3_22ae_4fed_37cde1756a41
  acea50f1_8324_3af6_8817_e44b2c4d3f18["WarDeploymentApplicationContextFactory()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| acea50f1_8324_3af6_8817_e44b2c4d3f18
  bdc58f3f_fee2_bfce_686e_2ce5f9aa4368["configure()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| bdc58f3f_fee2_bfce_686e_2ce5f9aa4368
  3b5ce68c_2b5f_b508_6e6a_e382ec1495f5["listeners()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| 3b5ce68c_2b5f_b508_6e6a_e382ec1495f5
  7e6ee8fe_25dc_0c28_46a0_629f3044d702["WebEnvironmentPropertySourceInitializer()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| 7e6ee8fe_25dc_0c28_46a0_629f3044d702
  edd11151_c5ef_29d5_a008_d115661e23bd["build()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| edd11151_c5ef_29d5_a008_d115661e23bd
  054bafb8_44ed_70f9_eaad_e693eb9d86e1["getAllSources()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| 054bafb8_44ed_70f9_eaad_e693eb9d86e1
  3b8969f2_1870_9992_b681_07000b6fab0a["addPrimarySources()"]
  6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 -->|calls| 3b8969f2_1870_9992_b681_07000b6fab0a
  style 6de23dd6_ba39_4c8b_2378_eb7c00e92ed5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

core/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java lines 155–182

	protected @Nullable WebApplicationContext createRootApplicationContext(ServletContext servletContext) {
		SpringApplicationBuilder builder = createSpringApplicationBuilder();
		builder.main(getClass());
		ApplicationContext parent = getExistingRootWebApplicationContext(servletContext);
		if (parent != null) {
			getLogger().info("Root context already created (using as parent).");
			servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, null);
			builder.initializers(new ParentContextApplicationContextInitializer(parent));
		}
		builder.initializers(new ServletContextApplicationContextInitializer(servletContext));
		builder.contextFactory(new WarDeploymentApplicationContextFactory(servletContext));
		builder = configure(builder);
		builder.listeners(new WebEnvironmentPropertySourceInitializer(servletContext));
		SpringApplication application = builder.build();
		if (application.getAllSources().isEmpty()
				&& MergedAnnotations.from(getClass(), SearchStrategy.TYPE_HIERARCHY).isPresent(Configuration.class)) {
			application.addPrimarySources(Collections.singleton(getClass()));
		}
		Assert.state(!application.getAllSources().isEmpty(),
				"No SpringApplication sources have been defined. Either override the "
						+ "configure method or add an @Configuration annotation");
		// Ensure error pages are registered
		if (this.registerErrorPageFilter) {
			application.addPrimarySources(Collections.singleton(ErrorPageFilterConfiguration.class));
		}
		application.setRegisterShutdownHook(false);
		return run(application);
	}

Domain

Subdomains

Calls

Called By

  • onStartup()

Frequently Asked Questions

What does createRootApplicationContext() do?
createRootApplicationContext() is a function in the spring-boot codebase.
What does createRootApplicationContext() call?
createRootApplicationContext() calls 16 function(s): ParentContextApplicationContextInitializer, WarDeploymentApplicationContextFactory, WebEnvironmentPropertySourceInitializer, addPrimarySources, build, configure, contextFactory, createSpringApplicationBuilder, and 8 more.
What calls createRootApplicationContext()?
createRootApplicationContext() is called by 1 function(s): onStartup.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free