What is the difference between @RepositoryRestController and the @Repository annotations?

user10244386 :

I want to know what exactly the difference between using the annotation @RepositoryRestController and @Repository because I've tried them both and I find absolutely no difference!

I tried the following:

@RepositoryRestResource
public interface MovieRepository extends JpaRepository<Movie, Short> { 
} 

and

@Repository
public interface MovieRepository extends JpaRepository<Movie, Short> { 
}

so when I try : /movies in both methods I get the same results.

And if I use @RepositoryRestController should I use @RepositoryRestController, or I can use @RestController, and is there any difference between them?

cassiomolin :

@Repository

@Repository is a stereotype interface for defining a repository originally defined by Domain-Driven Design (Evans, 2003) as "a mechanism for encapsulating storage, retrieval, and search behavior which emulates a collection of objects".

This annotation also serves as a specialization of @Component, allowing for implementation classes to be autodetected through classpath scanning.

@RepositoryRestResource

@RepositoryRestResource tells Spring Data REST to expose your repository as REST endpoints. Check the relevant part of the documentation.


If you want to write a custom handler for a specific resource taking advantage of Spring Data REST’s settings, message converters, exception handling and more, you can use @RepositoryRestController (instead of the standard Spring MVC @Controller or @RestController annotations). See the relevant part of the documentation.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=111105&siteId=1