【问题标题】:Is there another way to set spring.data.rest.base-path than properties which are ignored?除了被忽略的属性之外,还有另一种设置 spring.data.rest.base-path 的方法吗?
【发布时间】:2017-04-24 13:56:45
【问题描述】:

我的application.yml有这个

弹簧: 数据: 休息: 基本路径:/api

但它一直被我的配置忽略,它在 / 中启动存储库

有没有什么方法可以用java代码或者其他方式来配置它?

我找到了这个,但它有点过时了:

http://pavelmakhov.com/2016/02/spring-data-rest-change-base-path

【问题讨论】:

    标签: spring spring-boot spring-data spring-data-rest


    【解决方案1】:
    @Configuration
    class CustomRestMvcConfiguration {
    
      @Bean
      public RepositoryRestConfigurer repositoryRestConfigurer() {
    
        return new RepositoryRestConfigurerAdapter() {
    
          @Override
          public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
            configuration.setBasePath("/api")
          }
        };
      }
    }
    

    http://docs.spring.io/spring-data/rest/docs/current/reference/html/#_changing_the_base_uri

    【讨论】:

      猜你喜欢
      • 2019-10-16
      • 1970-01-01
      • 2012-10-01
      • 2021-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-17
      相关资源
      最近更新 更多