How to disable the default exposure of Spring Data REST repositories?(如何禁用 Spring Data REST 存储库的默认公开?)
问题描述
我有一个使用 spring-data-rest 的项目,并且有一个只使用 Spring Data 的依赖项目.两个项目都有spring数据仓库,都使用@EnableJpaRepositories
来实现它们的仓库接口,但是我只想导出父项目中的仓库.
I have a project that uses spring-data-rest, and has a dependency project that only uses Spring Data. Both projects have spring data repositories and use @EnableJpaRepositories
to implement their repository interfaces, but I only want to export the repositories in the parent project.
这是我的问题:是否有某种方法可以将 Spring Data REST 配置为仅公开父项目中资源的其余端点,而不必使用 @RepositoryRestResource(exported = false) 显式注释依赖项项目中的每个存储库
?
Here's my question: is there some way to configure Spring Data REST to only expose rest endpoints for resources in the parent project, without having to explicitly annotate every repository in the dependency project with @RepositoryRestResource(exported = false)
?
如果我只能通过禁用它的 @RepositoryRestResource
来做到这一点,更糟糕的是,没有其他具有不同用例的项目能够为这些存储库启用 REST 端点,我的依赖项目将必须包含 Spring Data REST 仅用于……
If I can only do this with @RepositoryRestResource
of disabling it, and worse yet, no other project with a different use case will be able to enable REST endpoints for those repositories, my dependency project will have to include Spring Data REST solely for the…
推荐答案
目前没有全局开关可以满足您的需求.我已经为您提交了这张票,以便包含在下一个主要版本中.
Currently there's no global switch for what you're looking for. I've filed this ticket for you for inclusion in the next major release.
不确定它是否适合您,但包私有存储库接口当前不公开,除非明确注释.如果您可以将所有这些库存储库包保护起来,这可能比显式注释更有利.
Not sure if it is an option for you but package private repository interfaces are not currently exposed unless explicitly annotated. If you can make all those library repositories package protected that might be favorable over the explicit annotation.
这篇关于如何禁用 Spring Data REST 存储库的默认公开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何禁用 Spring Data REST 存储库的默认公开?
基础教程推荐
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 降序排序:Java Map 2022-01-01