在文章[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