<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Spring Core on Java &amp; Software Architecture Knowledge Hub</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/core/</link><description>Recent content in Spring Core on Java &amp; Software Architecture Knowledge Hub</description><generator>Hugo</generator><language>en-US</language><copyright>© 2026 Samir Kumar Sahoo (https://github.com/samirsahoo). All rights reserved.</copyright><atom:link href="https://samirsahoo.github.io/design-patterns-hub/spring/core/index.xml" rel="self" type="application/rss+xml"/><item><title>Dependency Injection in Java</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/core/dependency-injection/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/core/dependency-injection/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Dependency injection (DI)&lt;/strong&gt; means an object receives the objects it works with — its &lt;em&gt;dependencies&lt;/em&gt; — from outside, instead of creating or looking them up itself.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Without DI: the service decides which notifier it uses.&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;private&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;final&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Notifier&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;notifier&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;EmailNotifier&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// With DI: whoever creates the service decides.&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;OrderService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Notifier&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;notifier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;notifier&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;notifier&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That is the entire idea. Frameworks such as Spring automate the wiring, but DI itself needs no framework.&lt;/p&gt;</description></item><item><title>Inversion of Control: ApplicationContext and BeanFactory</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/core/applicationcontext-and-beanfactory/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/core/applicationcontext-and-beanfactory/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Inversion of Control (IoC)&lt;/strong&gt; means your objects do not create or look up their collaborators: a &lt;strong&gt;container&lt;/strong&gt; creates them, wires them and manages their lifecycle. In Spring, that container is the &lt;strong&gt;&lt;code&gt;ApplicationContext&lt;/code&gt;&lt;/strong&gt;, built on the lower-level &lt;strong&gt;&lt;code&gt;BeanFactory&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Bean Lifecycle and Scopes</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/core/bean-lifecycle-and-scopes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/core/bean-lifecycle-and-scopes/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The &lt;strong&gt;bean lifecycle&lt;/strong&gt; is the sequence of steps Spring performs to create, initialise, use and destroy a bean. A bean&amp;rsquo;s &lt;strong&gt;scope&lt;/strong&gt; decides &lt;strong&gt;how many instances&lt;/strong&gt; exist and &lt;strong&gt;how long&lt;/strong&gt; each lives.&lt;/p&gt;&#10;&lt;h2 id="the-problem"&gt;The problem&lt;a class="heading-anchor" href="#the-problem" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Opening connections in a constructor before properties are injected, forgetting to close thread pools on shutdown, or storing per-user data in a singleton are common, serious bugs. Knowing the lifecycle tells you &lt;strong&gt;where&lt;/strong&gt; code belongs; knowing scopes tells you what is &lt;strong&gt;shared&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Spring Configuration: @Configuration, @Bean, Component Scanning and Profiles</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/core/configuration-and-component-scanning/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/core/configuration-and-component-scanning/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Spring learns &lt;strong&gt;which beans to create&lt;/strong&gt; in three main ways:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;Component scanning&lt;/strong&gt;: annotate your classes (&lt;code&gt;@Component&lt;/code&gt;, &lt;code&gt;@Service&lt;/code&gt; and so on) and Spring finds them.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Java configuration&lt;/strong&gt;: &lt;code&gt;@Bean&lt;/code&gt; factory methods inside &lt;code&gt;@Configuration&lt;/code&gt; classes, ideal for third-party classes you cannot annotate.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Auto-configuration&lt;/strong&gt;: Spring Boot&amp;rsquo;s conditional defaults. See &lt;a href="https://samirsahoo.github.io/design-patterns-hub/spring/boot/auto-configuration-and-conditions/"&gt;auto-configuration&lt;/a&gt;.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;h2 id="the-problem"&gt;The problem&lt;a class="heading-anchor" href="#the-problem" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Without a clear configuration strategy, applications end up with duplicate beans, surprising overrides, beans scanned from the wrong packages, and environment-specific code paths scattered everywhere.&lt;/p&gt;</description></item><item><title>Spring Expression Language (SpEL)</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/core/spring-expression-language/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/core/spring-expression-language/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;SpEL (Spring Expression Language)&lt;/strong&gt; is a small expression language that Spring evaluates &lt;strong&gt;at runtime&lt;/strong&gt; against objects, beans and context. It powers dynamic values in annotations such as &lt;code&gt;@Value(&amp;quot;#{…}&amp;quot;)&lt;/code&gt;, &lt;code&gt;@PreAuthorize(&amp;quot;…&amp;quot;)&lt;/code&gt;, &lt;code&gt;@Cacheable(key = &amp;quot;…&amp;quot;)&lt;/code&gt; and &lt;code&gt;@EventListener(condition = &amp;quot;…&amp;quot;)&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Aspect-Oriented Programming (AOP), Advice Types and Proxies</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/core/aop-and-proxies/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/core/aop-and-proxies/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Aspect-oriented programming (AOP)&lt;/strong&gt; keeps &lt;strong&gt;cross-cutting concerns&lt;/strong&gt; (logging, transactions, security, metrics, retries, caching) out of business code. You write the concern once as an &lt;strong&gt;aspect&lt;/strong&gt; and declare &lt;strong&gt;where&lt;/strong&gt; it applies. Spring AOP applies aspects by wrapping beans in &lt;strong&gt;proxies&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Spring Application Events and Listeners</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/core/application-events/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/core/application-events/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Spring&amp;rsquo;s &lt;strong&gt;application events&lt;/strong&gt; let one bean &lt;strong&gt;publish&lt;/strong&gt; a message (&amp;ldquo;an order was placed&amp;rdquo;) and any number of other beans &lt;strong&gt;listen&lt;/strong&gt; and react, without the publisher knowing them. It is the Observer pattern, implemented by the &lt;code&gt;ApplicationContext&lt;/code&gt;, &lt;strong&gt;inside one application&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>