And*_*res 10 java spring spring-data spring-data-jpa spring-data-rest
我已经在jpa存储库中添加了一个自定义方法,详见http://docs.spring.io/spring-data/data-jpa/docs/1.0.x/reference/html/#repositories.custom-implementations
据我所知,当我使用spring-data-rest时,这个方法不会暴露.有没有什么办法可以将它作为spring-data-rest生成的REST API的一部分发布(不用自己创建Spring MVC Controller)?
Fai*_*roz 11
我检查了代码库 - 似乎他们已经明确禁用自定义方法 - 不知道为什么.以下是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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4648 次 |
| 最近记录: |