Loading

Spring Data Rest如何暴露ID字段

/**
 * restful默认不返回主键id, 需要新增配置文件
 */
@Configuration
class SpringDataRestConfig {
    @Bean
    public RepositoryRestConfigurer repositoryRestConfigurer() {
        return new RepositoryRestConfigurerAdapter() {
            @Override
            public void configureRepositoryRestConfiguration( RepositoryRestConfiguration config) {
                config.exposeIdsFor(Channel.class, Product.class, SysAccount.class, Dealer.class, ProductSku.class,AppVersion.class);
                config.exposeIdsFor(CustomerStatus.class);
                config.exposeIdsFor(Campaign.class);
                config.exposeIdsFor(Function.class);
                config.setDefaultMediaType(org.springframework.http.MediaType.APPLICATION_JSON);
                config.setDefaultPageSize(1000);
            }
        };
    }

}

 

posted @ 2017-07-26 19:17  yaro-feng  阅读(1221)  评论(0编辑  收藏  举报