Constructor injection vs Setter injection in Spring Framework

0 votes

Can someone differentiate between constructor injection and setter injection?

Aug 29, 2018 in Java by 93.lynn
• 1,570 points
352 views

1 answer to this question.

0 votes

Here, I have listed down few differences. Hope it helps.

Constructor Injection

Setter Injection

There is no partial injection.

There can be a partial injection.

It doesn’t override the setter property.

It overrides the constructor property.

It will create a new instance if any modification is done.

It will not create a new instance if any modification is done.

It works better for many properties.

It works better for a few properties.

answered Aug 29, 2018 by anto.trigg4
• 3,420 points

Related Questions In Java

0 votes
1 answer

@Component vs @Repository vs @Service in Spring Framework

As you might be knowing, all these ...READ MORE

answered May 29, 2018 in Java by geek.erkami
• 2,320 points
812 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Types of transaction management in Spring Framework

Well there are basically to types of ...READ MORE

answered Nov 27, 2018 in Java by geek.erkami
• 2,320 points
254 views
0 votes
1 answer

Configuration metadata in Spring Framework

Configuration metadata can be provided to Spring container in ...READ MORE

answered Aug 2, 2018 in Java by code.reaper12
• 3,450 points
1,195 views
0 votes
1 answer

@Autowired annotation in Spring Framework

The @Autowired annotation provides more accurate control over where ...READ MORE

answered Aug 2, 2018 in Java by geek.erkami
• 2,320 points
129 views
0 votes
1 answer

Types of IOC containers in Spring Framework

There are basically two types of IOC ...READ MORE

answered Aug 27, 2018 in Java by misc.edu04
• 1,380 points
279 views
0 votes
1 answer

Spring configuration file

A Spring configuration file is an XML ...READ MORE

answered Aug 27, 2018 in Java by v.liyyah
• 1,300 points
24 views
0 votes
1 answer

Retrieve all the implementations of an interface in Java

Hi...I think you can achieve this by ...READ MORE

answered Jul 23, 2018 in Java by anto.trigg4
• 3,420 points
807 views
0 votes
1 answer

SuppressWarnings (“unchecked”) in Java

@SuppressWarnings("unchecked") is used when Java generics just don't ...READ MORE

answered Sep 4, 2018 in Java by anto.trigg4
• 3,420 points
76 views