我在jpa存储库中添加了一个自定义方法,详见http://docs.spring.io/spring-data/data-jpa/docs/1.0.x/reference/html/#repositories.custom-implementations
据我所见,当我使用spring-data-rest时,没有公开此方法。我是否可以将其作为生成的REST的一部分发布(而无需自己创建Spring控制器)?
发布于 2014-02-01 19:30:10
我检查了代码库--似乎它们已经明确地禁用了自定义方法--不确定原因。以下是来自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);
}https://stackoverflow.com/questions/21116539
复制相似问题