Spring- Difference and use case @Repository and @RepositoryRestResource?

Viewed 1866

When I started to use spring boot I was annotating my interface with @Repositoryall these days I was following the same, but today I happened to come across annotating with another way called @RepositoryRestResource. What is the difference between them, When is it used.

3 Answers

In addition to answer mentioned above, you can also customize your REST endpoints using @RepositoryRestResource.

The @Repository annotation enables exception translation so you can handle Springs DataAccessException instead of underlying persistence implementation exceptions (via PersistenceExceptionTranslationPostProcessor). @RepositoryRestResource is not a specialization of @Repository so you might want in include both, to expose REST endpoints and enable exception translation.

Related