Can @Component, @Repository and @Service annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device?>
There is no difference between @Component
, @Service
, @Controller
, @Repository
.
@Component
is the Generic annotation to represent the component of our MVC. But there will be several components as part of our MVC application like service layer components, persistence layer components and presentation layer components. So to differentiate them Spring people have given the other three annotations also.
@Repository
@Service
@Controller
@Component
for all of them.