<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://rasimsen.com/index.php?action=history&amp;feed=atom&amp;title=Setter-Based_Dependency_Injection</id>
	<title>Setter-Based Dependency Injection - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://rasimsen.com/index.php?action=history&amp;feed=atom&amp;title=Setter-Based_Dependency_Injection"/>
	<link rel="alternate" type="text/html" href="http://rasimsen.com/index.php?title=Setter-Based_Dependency_Injection&amp;action=history"/>
	<updated>2026-04-23T05:50:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>http://rasimsen.com/index.php?title=Setter-Based_Dependency_Injection&amp;diff=181&amp;oldid=prev</id>
		<title>Rasimsen: Created page with &quot;For setter-based DI, the container will call setter methods of our class, after invoking a no-argument constructor or no-argument static factory method to instantiate the bean...&quot;</title>
		<link rel="alternate" type="text/html" href="http://rasimsen.com/index.php?title=Setter-Based_Dependency_Injection&amp;diff=181&amp;oldid=prev"/>
		<updated>2018-06-03T11:31:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;For setter-based DI, the container will call setter methods of our class, after invoking a no-argument constructor or no-argument static factory method to instantiate the bean...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;For setter-based DI, the container will call setter methods of our class, after invoking a no-argument constructor or no-argument static factory method to instantiate the bean. Let’s create this configuration using annotations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
@Bean&lt;br /&gt;
public Store store() {&lt;br /&gt;
    Store store = new Store();&lt;br /&gt;
    store.setItem(item1());&lt;br /&gt;
    return store;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can also use XML for the same configuration of beans:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&amp;quot;store&amp;quot; class=&amp;quot;org.baeldung.store.Store&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;item&amp;quot; ref=&amp;quot;item1&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Constructor-based and setter-based types of injection can be combined for the same bean. The Spring documentation recommends using constructor-based injection for mandatory dependencies, and setter-based injection for optional ones.&lt;/div&gt;</summary>
		<author><name>Rasimsen</name></author>
		
	</entry>
</feed>