Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is Difference between @Service and @Component annotation in Spring

 
Sijesh Alayaril
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi All,

When developing a web application ,in service layer i found @service annotation but i'm not clear about the functionality of that annotation.Anyone could you please help me to understand this .


Thanks in Advance...


Cheers




 
Ken Rimple
author
Ranch Hand
Posts: 63
Mac OS X Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default, nothing.

But, you can use @Service in AOP wirings, so that you can wrap all services with security, or transactions, etc...

So, it' really a stereotype, a classification.

In the future, maybe Spring will do something different with that, they reserve the right, but for now it's primarily so you can organize your own objects and identify them properly.

Ken
 
Sijesh Alayaril
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Ken..





 
Sijesh Alayaril
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is @Autowired annotations is fulfill the concept of IOC or DI in Spring ?
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Using the @Autowired or @Inject annotations is how your object defines its dependencies the container then injects those dependencies when it creates the bean.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic