我添加了一個自定義的方法到JPA存儲庫作爲至於我能看到http://docs.spring.io/spring-data/data-jpa/docs/1.0.x/reference/html/#repositories.custom-implementationsJPA庫法
詳細的,當我用這個方法不會暴露彈簧數據休息。有什麼方法可以將它作爲spring-data-rest生成的REST API的一部分發布(不需要自己創建Spring MVC Controller)?
我添加了一個自定義的方法到JPA存儲庫作爲至於我能看到http://docs.spring.io/spring-data/data-jpa/docs/1.0.x/reference/html/#repositories.custom-implementationsJPA庫法
詳細的,當我用這個方法不會暴露彈簧數據休息。有什麼方法可以將它作爲spring-data-rest生成的REST API的一部分發布(不需要自己創建Spring MVC Controller)?
我檢查了代碼庫 - 好像他們有可明確禁用自定義的方法 - 不知道爲什麼。這裏是來自org.springframework.data.repository.core.support.DefaultRepositoryInformation的相關代碼段
@Override
public Set<Method> getQueryMethods() {
Set<Method> result = new HashSet<Method>();
for (Method method : getRepositoryInterface().getMethods()) {
method = ClassUtils.getMostSpecificMethod(method, getRepositoryInterface());
if (isQueryMethodCandidate(method)) {
result.add(method);
}
}
return Collections.unmodifiableSet(result);
}
/**
* Checks whether the given method is a query method candidate.
*
* @param method
* @return
*/
private boolean isQueryMethodCandidate(Method method) {
return isQueryAnnotationPresentOn(method) || !isCustomMethod(method) && !isBaseClassMethod(method);
}
我也面臨同樣的問題。任何幫助,將不勝感激。 –