在Spring数据REST中更改资源路径

在Spring数据REST中更改资源路径,spring,spring-data,spring-data-rest,Spring,Spring Data,Spring Data Rest,使用SpringDataREST,我希望将特定资源的路径更改为前缀,即http://example.net/api/customprefix/myresourcevs.http://example.net/api/myresource @RepositoryRestResource(path = "customprefix/myresource", collectionResourceRel = "myresources") public interface MyResourceReposito

使用SpringDataREST,我希望将特定资源的路径更改为前缀,即
http://example.net/api/customprefix/myresource
vs.
http://example.net/api/myresource

@RepositoryRestResource(path = "customprefix/myresource", collectionResourceRel = "myresources")
public interface MyResourceRepository extends PagingAndSortingRepository<MyResource, UUID> { }
我知道如何使用
application.properties
中的
Spring.Data.REST.base path
指令更改Spring Data REST项目的基本路径,并且该指令当前设置为
/api

我尝试了以下方法,但在
http://example.net/api/customprefix/myresource

@RepositoryRestResource(path = "customprefix/myresource", collectionResourceRel = "myresources")
public interface MyResourceRepository extends PagingAndSortingRepository<MyResource, UUID> { }
@RepositoryRestResource(path=“customprefix/myresource”,collectionResourceRel=“myresources”)
公共接口MyResourceRepository扩展了分页和排序存储库{}

是否可以使用Spring Data REST为一个资源或一组资源设置自定义前缀?

您想做的设计是不可能的:

基本上,您没有理由希望这样做,因为服务器或客户端不需要知道或理解URI的含义。
customprefix
对服务器或客户端没有任何意义。您可以使用camel case或类似的东西来提高URI的可读性

在您的情况下,即
path=“customprefix myresource”