From Spring Documentation:
@Repositoryannotation is a marker for any class that fulfils the
role or stereotype of a repository (also known as Data Access Object
or DAO). Among the uses of this marker is the automatic translation of
exceptions, as described in Exception Translation.
Spring provides further stereotype annotations:
@Componentis a generic stereotype for any
@Componentfor more specific use cases (in the
persistence, service, and presentation layers, respectively).
Therefore, you can annotate your component classes with
but, by annotating them with
instead, your classes are more properly suited for processing by tools
or associating with aspects.
For example, these stereotype annotations
make ideal targets for pointcuts.
@Controllercan also carry additional semantics in future releases of
the Spring Framework. Thus, if you are choosing between using
@Servicefor your service layer,
@Serviceis clearly the
better choice. Similarly, as stated earlier,
supported as a marker for automatic exception translation in your
||generic stereotype for any Spring-managed component|
||stereotype for persistence layer|
||stereotype for service layer|
||stereotype for presentation layer (spring-mvc)|