<div dir="ltr" style="text-align: justify;">
<p>&#8220;<b>application-context</b>&#8221; in spring means nothing but it is core component of spring container in spring framework. Ideally we can say &#8220;application-context&#8221; one of the Spring Container in Spring Framework and other container is &#8220;bean-factory&#8221;. The configuration for &#8220;application-context&#8221; is loaded by the one of concrete implementation of <b>ApplicationContext </b>interface.</p>
<div id="ads-id" align="center"></div>
<p>The <b>ApplicationContext </b>is the central interface within a Spring Application for providing configuration information to the application. It is read-only at run time , but can be reloaded if necessary and supported by the application.</p>
<div style="background-color: #f2f9fc; border: 1px solid #c9e6f2; border-radius: 3px; padding: 16px; line-height: 1.45;"><span style="color: red; font-size: x-large; text-align: center;"><b>Popular Tutorials</b></span></p>
<ul style="text-align: left;">
<li><b><a href="https://dineshonjava.com/spring-tutorial/"><em><strong>Spring Tutorial</strong> </em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-web-mvc-framework-chapter-38/"><strong><em>Spring MVC Web Tutorial </em></strong></a></b></li>
<li><b><a href="https://dineshonjava.com/introduction-to-spring-boot-a-spring-boot-complete-guide/"><strong>Spring Boot Tutorial</strong> </a></b></li>
<li><b><a href="https://dineshonjava.com/spring-security-take-baby-step-to-secure/"><em>Spring Security Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-aop-tutorial-with-example-aspect-advice-pointcut-joinpoint/"><em>Spring AOP Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/using-spring-jdbc-framework-chapter-32/"><em>Spring JDBC Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-hateoas-hypermedia-driven-restful-web-service/"><em><strong>Spring HATEOAS </strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/microservices-with-spring-boot/"><em><strong>Microservices with Spring Boot</strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/jax-rs-web-service-tutorial/"><strong><em>REST Webservice</em> </strong></a></b></li>
<li><b><a href="https://dineshonjava.com/core-java-baby-step-to-be-best-java-ian/"><em><strong>Core Java </strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/hibernate-3-on-baby-steps/"><em><strong>Hibernate Tutorial</strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-batch-process-with-example/"><strong><em>Spring Batch</em> </strong></a></b></li>
</ul>
</div>
<p><b>Major Responsibilities of &#8220;<i>application-context</i>&#8221; container</b></p>
<div class="separator" style="clear: both; text-align: center;"><img title="application-context in Spring" src="https://i0.wp.com/dineshonjava.com/wp-content/uploads/2016/11/application-context.jpg" border="0" /></div>
<ul style="text-align: left;">
<li>It provides bean factory methods for accessing application components.</li>
<li>It provides the ability to load file resources in a generic fashion.</li>
<li>It provides the ability to publish event to register listeners</li>
<li>It provide the ability to resolve to support internationalization.</li>
</ul>
<p><b>Creating one &#8220;<i>application-context</i>&#8220;</b></p>
<ul style="text-align: left;">
<li><b>AnnotationConfigApplicationContext</b>. Loads a Spring application context from one or moro Java-Based configuration classes.
<pre class="highlight">ApplicationContext context = new AnnotationConfigApplicationContext(JavaConfig.class; 
</pre>
</li>
<li><b>AnnotationConfigWebApplicationContext</b>. Loads a Spring web application context from one or more Java-Based configuration classes.
<pre class="highlight">ApplicationContext context = new AnnotationConfigWebApplicationContext(JavaWebConfig.class; 
</pre>
</li>
<li><b>ClassPathXMLApplicationContext</b>. Loads a context definition from one or more XML files located in the classpath
<pre class="highlight">ApplicationContext context = new ClassPathXMLApplicationContext("spingConfig.xml"); 
</pre>
</li>
<li><b>FileSystemXMLApplicationContext</b>. Loads a context definition from one or more XML files located in the filesystem.
<pre class="highlight">ApplicationContext context = new FileSystemXMLApplicationContext("c:/spingConfig.xml"); 
</pre>
</li>
<li><b>XMLWebApplicationContext</b>. Loads a context definition from one or more XML files contained in the web application.
<pre class="highlight">ApplicationContext context = new XMLWebApplicationContext("/WEB-INF/config/spingConfig.xml"); 
</pre>
</li>
</ul>
<p>Accessing Application Context in the other classes:<br />
You could also access the &#8220;application-context&#8221; container into other classes. You can implement ApplicationContextAware as in the following example:</p>
<pre class="highlight">public class AnotherClass implements ApplicationContextAware { 
 
 private ApplicationContext applicationContext; 
 
 @Override 
 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 
 this.applicationContext = applicationContext; 
 } 
 
} 
 
</pre>
<div style="background-color: #f2f9fc; border: 1px solid #c9e6f2; border-radius: 3px; padding: 16px; line-height: 1.45;"><span style="color: red; font-size: x-large; text-align: center;"><b>Spring MVC Related Posts</b></span></p>
<ul>
<li><b><a href="https://dineshonjava.com/spring-web-mvc-framework-chapter-38/"><span style="color: red;">Spring MVC Web Tutorial</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-mvc-interview-questions-and-answers/"><span style="color: red;">Spring MVC Interview Questions</span></a></b></li>
<li><b><a href="https://dineshonjava.com/introduction-to-mvc/"><span style="color: red;">MVC Design Pattern</span></a></b></li>
<li><b><a href="https://dineshonjava.com/what-is-dispatcherservlet-in-spring-and-its-uses/"><span style="color: red;">Spring MVC DispatcherServlet </span></a></b></li>
<li><b><a href="https://dineshonjava.com/difference-between-applicationcontext-webapplicationcontext-in-spring-mvc/"><span style="color: red;">Spring MVC WebApplicationContext and Root Application Context</span></a></b></li>
<li><b><a href="https://dineshonjava.com/stereotype-annotations-in-spring/"><span style="color: red;">Spring MVC @Controller Annotation</span></a></b></li>
<li><b><a href="https://dineshonjava.com/requestmapping-annotation-in-spring-mvc/"><span style="color: red;">Spring MVC @RequestMapping Annotation</span></a></b></li>
<li><b><a href="https://dineshonjava.com/requestparam-annotation-in-spring-mvc-with-example/"><span style="color: red;">Spring MVC @RequestParam Annotation</span></a></b></li>
<li><b><a href="https://dineshonjava.com/difference-between-applicationcontext-webapplicationcontext-in-spring-mvc/"><span style="color: red;">Spring MVC ContextLoaderListener</span></a></b></li>
<li><b><a href="https://dineshonjava.com/requestparam-vs-pathvariable-annotations-in-spring-mvc/"><span style="color: red;">Spring MVC @RequestParam and @PathVariable annotations</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-30-mvc-hello-world-example/"><span style="color: red;">Spring MVC Hello World Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-exception-handling-example/"><span style="color: red;">Spring MVC Exception Handling Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-mvc-with-hibernate-crud-example/"><span style="color: red;">Spring MVC with Hibernate CRUD Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-3-mvc-tiles-plugin-with-example/"><span style="color: red;">Spring MVC Tiles Plugin with Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-3-mvc-and-interceptor-with/"><span style="color: red;">Spring MVC Interceptor with example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/integration-spring-mvc3-and-mongodb/"><span style="color: red;">Spring MVC with MongoDB CRUD Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-3-mvc-internationalization/"><span style="color: red;">Spring MVC Internationalization &; Localization with Example</span></a></b></li>
</ul>
<p> ;</p>
</div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/what-is-interface-and-what-are-the-advantages-of-making-use-of-them-in-java/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/jsr-330-annotations-in-spring/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '100'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…