spring boot 使用 spring data rest
2016-10-17 15:44
579 查看
1. 引入rest依赖
2. 两种配置方式:
application.properties配置
继承RepositoryRestMvcConfiguration配置类
覆写configureRepositoryRestConfiguration方法
使用配置类将使得配置文件配置无效,通常情况下rest返回的资源是不带id属性的,可以使用配置类的方式暴露出来。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> </dependency>
2. 两种配置方式:
application.properties配置
//根路径 spring.data.rest.base-path:java.net.URI //默认分页大小 spring.data.rest.default-page-size:int spring.data.rest.limit-param-name:String spring.data.rest.max-page-size:int spring.data.rest.page-param-name:String //创建成功是否返回该资源体 spring.data.rest.return-body-on-create:boolean //更新成功是否返回该资源体 spring.data.rest.return-body-on-update:boolean
继承RepositoryRestMvcConfiguration配置类
覆写configureRepositoryRestConfiguration方法
@Configuration public class RestConfiguration extends RepositoryRestMvcConfiguration { @Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { //暴露id属性,可多类 config.exposeIdsFor(User.class, Promission.class...); //设置根路径 config.setBasePath("data"); } }
使用配置类将使得配置文件配置无效,通常情况下rest返回的资源是不带id属性的,可以使用配置类的方式暴露出来。
相关文章推荐
- spring boot 使用 spring data jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- Spring Boot中使用Spring-data-jpa让数据访问更简单、更优雅
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- Spring Boot-使用Spring Data JPA简化数据库访问
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- spring boot RestTemplate 发送 get 请求使用误区
- springboot-data-rest
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- Spring Boot中使用Spring-data-jpa让数据访问更简单、更优雅
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa
- 深入学习spring-boot系列(二)--使用spring-data-jpa