Component vs Controller vs Repository vs Service annotations in Spring Framework

0 votes

What’s the difference between @Component, @Controller, @Repository & @Service annotations in Spring?

Nov 28, 2018 in Java by 93.lynn
• 1,600 points
12,392 views

1 answer to this question.

0 votes

@Component: This marks a java class as a bean. It is a generic stereotype for any Spring-managed component. The component-scanning mechanism of spring now can pick it up and pull it into the application context.

annotations - Spring Framework Tutorial - Edureka!

@Controller: This marks a class as a Spring Web MVC controller. Beans marked with it are automatically imported into the Dependency Injection container.

@Service: This annotation is a specialization of the component annotation. It doesn’t provide any additional behavior over the @Component annotation. You can use @Service over @Component in service-layer classes as it specifies intent in a better way.

@Repository: This annotation is a specialization of the @Component annotation with similar use and functionality. It provides additional benefits specifically for DAOs. It imports the DAOs into the DI container and makes the unchecked exceptions eligible for translation into Spring DataAccessException.

Hope this hepls!

answered Nov 28, 2018 by code.reaper12
• 3,500 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,650 views
0 votes
1 answer

Constructor injection vs Setter injection in Spring Framework

Here, I have listed down few differences. ...READ MORE

answered Aug 30, 2018 in Java by anto.trigg4
• 3,440 points
3,222 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
26,622 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,909 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,743 views
0 votes
1 answer

@RequestMapping annotation in Java Spring

The @RequestMapping annotation in Spring Framework is ...READ MORE

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

Annotation wiring in Spring

By default, Annotation wiring is not turned ...READ MORE

answered Jul 4, 2018 in Java by code.reaper12
• 3,500 points
1,143 views
0 votes
1 answer

Various Advice in Spring AOP

Below are the various advices available in AOP: Before: These types ...READ MORE

answered Sep 12, 2018 in Java by geek.erkami
• 2,680 points
1,362 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,549 views
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,797 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