我在Repo上定义了这样的摘录:
@RepositoryRestResource(excerptProjection = ListAccountProjection.class)
public interface IAccountRepository extends IRepository<Account> {
当我执行GET /帐户时,它会像预期的那样工作。
我有另一个Projection ShortAccountProjection。
当我执行GET / accounts?projection = short时,它会被忽略。那么投影参数永远不会覆盖回购的exerpt投影?
当我从回购中删除摘录时,投影&#34;排序&#34;按预期工作。
答案 0 :(得分:2)
如果您定义了摘录投影,则始终在访问集合资源时应用它(在您的情况下为/accounts
),或者在另一个资源中将资源添加为 _embedded 。< / p>
您的 ShortAccountProjection 仅适用于商品资源(例如GET /accounts/{id}?projection=short
)。
最后,请查看Why is an excerpt projection not applied automatically for a Spring Data REST item resource?