2015-02-04 86 views
14

我有一個使用spring-data-rest的項目,並且有一個只使用Spring Data的依賴項目。這兩個項目都有彈簧數據存儲庫,並使用@EnableJpaRepositories來實現它們的存儲庫接口,但我只想導出父項目中的存儲庫。如何禁用Spring Data REST存儲庫的默認暴露?

這裏是我的問題:是否有一些方法可以配置Spring Data REST,以便僅暴露父項目中資源的其餘端點,而不必顯式註釋依賴項目中的每個存儲庫與@RepositoryRestResource(exported = false)

如果我只能這樣做有其禁用@RepositoryRestResource,更糟的是,沒有其他的項目有不同的使用情況下,將能夠啓用這些倉庫REST端點,我依賴的項目必須包括春季數據REST只爲...

回答

13

目前沒有全球開關爲您尋找什麼。我已爲您提交this ticket以包含在下一個主要版本中。

不確定它是否是您的選擇,但包當前未公開存儲庫私有存儲庫接口,除非明確註釋。如果您可以使所有這些庫存儲庫受到保護,這可能比明確的註釋更有利。

+2

作出的回購包專用。感謝您創建該票證。 – gyoder

12

當我正在尋找這個特定的設置時,回到這裏。看起來這現在已經實現了。在這種情況下,您需要設置spring.data.rest.detection-strategy =註釋以避免默認曝光。

所有application.properties選項:

# Exposes all public repository interfaces but considers @(Repository)RestResource\u2019s `exported flag. 
spring.data.rest.detection-strategy=default 

# Exposes all repositories independently of type visibility and annotations. 
spring.data.rest.detection-strategy=all 

# Only repositories annotated with @(Repository)RestResource are exposed, unless their exported flag is set to false. 
spring.data.rest.detection-strategy=annotated 

# Only public repositories annotated are exposed. 
spring.data.rest.detection-strategy=visibility 

參考:4.6.1. Which repositories get exposed by defaults?

相關問題