![](/img/trans.png)
[英]What is the difference between @Entity and @Repository annotations?
[英]What is the difference between @RepositoryRestController and the @Repository annotations?
我想知道使用注釋@RepositoryRestController
和@Repository
之間究竟有什么區別,因為我已經嘗試了它們兩個並且我發現完全沒有區別!
我嘗試了以下方法:
@RepositoryRestResource
public interface MovieRepository extends JpaRepository<Movie, Short> {
}
和
@Repository
public interface MovieRepository extends JpaRepository<Movie, Short> {
}
所以當我嘗試: /兩種方法中的電影時 ,我得到相同的結果。
如果我用@RepositoryRestController
我應該使用@RepositoryRestController
,或者我可以使用@RestController
,並且它們之間有什么區別嗎?
@Repository
@Repository
是一個@Repository
型接口,用於將最初由Domain-Driven Design(Evans,2003)定義的存儲庫定義為“封裝模擬對象集合的存儲,檢索和搜索行為的機制” 。
此注釋還用作@Component
,允許通過類路徑掃描自動檢測實現類。
@RepositoryRestResource
@RepositoryRestResource
告訴Spring Data REST將您的存儲庫公開為REST端點。 檢查文檔的相關部分。
如果要利用Spring Data REST的設置,消息轉換器,異常處理等為特定資源編寫自定義處理程序,可以使用@RepositoryRestController
(而不是標准的Spring MVC @Controller
或@RestController
注釋)。 請參閱文檔的相關部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.