Constructor injection vs Setter injection in Spring Framework

0 votes

Can someone differentiate between constructor injection and setter injection?

Aug 30, 2018 in Java by 93.lynn
• 1,600 points
2,990 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 30, 2018 by anto.trigg4
• 3,440 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,680 points
3,335 views
0 votes
1 answer
0 votes
1 answer

@Qualifier annotation in Spring Framework

When you create more than one bean ...READ MORE

answered Sep 10, 2018 in Java by code.reaper12
• 3,500 points
1,553 views
0 votes
1 answer

Types of transaction management in Spring Framework

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

answered Nov 28, 2018 in Java by geek.erkami
• 2,680 points
1,687 views
0 votes
1 answer

Configuration metadata in Spring Framework

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

answered Aug 3, 2018 in Java by code.reaper12
• 3,500 points
12,066 views
0 votes
1 answer

@Autowired annotation in Spring Framework

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

answered Aug 3, 2018 in Java by geek.erkami
• 2,680 points
1,431 views
0 votes
1 answer

Types of IOC containers in Spring Framework

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

answered Aug 28, 2018 in Java by misc.edu04
• 1,450 points
25,267 views
0 votes
1 answer

Spring configuration file

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

answered Aug 28, 2018 in Java by v.liyyah
• 1,300 points
6,126 views
+1 vote
2 answers

Retrieve all the implementations of an interface in Java

Take a look to this example: https://github.com/burningwave/co ...READ MORE

answered Dec 21, 2019 in Java by Roberto
• 460 points

edited Jul 7, 2020 by Roberto 36,674 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,440 points
8,357 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP