在文章[Spring Boot] - RESTful {Controller層的業務設計}中,經過在Controller中引入xxxRepository來對外提供REST API。Spring Boot還能夠經過spring-boot-starter-data-rest
來對外提供REST API,能夠免於編寫對應的Controller,且具有分頁和排序的功能。html
官網:User Guides前端
在pom文件中添加Spring Boot 對Data REST支持的依賴項:spring
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> </dependency>
@RepositoryRestResource註解讓編程人員能夠直接經過repository提供數據接口,在這個「前端負責V和C,後端負責提供數據」的時代,很是方便;而且,能夠經過給該註解傳入參數來改變URL。編程
只要在項目的classpath中包含spring-boot-starter-data-rest,同時就包含了spring-hateoas庫支持,這個庫能夠提供ALPS元數據——一種數據格式,能夠用於描述應用級別的API語義。後端
ALPS主頁ide
Spring Data Rest + Spring Secuirtyspring-boot
文/杜琪(簡書做者)
原文連接:http://www.jianshu.com/p/3ea7170a1099
著做權歸做者全部,轉載請聯繫做者得到受權,並標註「簡書做者」。ui