簡體   English   中英

外部存儲庫和存儲庫實現

[英]External repository and repository implementation

在 Spring Boot 應用程序中使用的存儲庫(位於主模塊中):

@Repository
public interface PersonRepository extends MongoRepository<Person, String>, AzureRepository<Person, String> {

}

存儲庫和存儲庫的實現(這些位於不同的 maven 模塊中):

public interface AzureRepository<T, ID> {

    boolean customUpdate(T entity);

}

public class AzureRepositoryImpl<T, ID> implements AzureRepository<T, ID> {
  ...
}

此配置會產生以下錯誤:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property customUpdate found for type Person!

當所有內容都在同一個 maven 模塊中時,自定義存儲庫及其實現工作正常。 但是當自定義存儲庫及其實現被放置在實用程序 maven 模塊中時,就會拋出上面的錯誤。

我應該使用@EnableMongoRepositories來指定外部存儲庫的基本包,而不是使用@EnableJpaRepositories

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM