繁体   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