简体   繁体   English

外部存储库和存储库实现

[英]External repository and repository implementation

The repository that is being used in the Spring Boot application (this is located in the main module):在 Spring Boot 应用程序中使用的存储库(位于主模块中):

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

}

The repository and implementation of the repository (these are located in a different maven module):存储库和存储库的实现(这些位于不同的 maven 模块中):

public interface AzureRepository<T, ID> {

    boolean customUpdate(T entity);

}

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

This configuration produces the following error:此配置会产生以下错误:

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

The custom repository and its implementation works fine when everything is in the same maven module.当所有内容都在同一个 maven 模块中时,自定义存储库及其实现工作正常。 But when the custom repository and its implementation are placed in the utility maven module then the error from above gets thrown.但是当自定义存储库及其实现被放置在实用程序 maven 模块中时,就会抛出上面的错误。

我应该使用@EnableMongoRepositories来指定外部存储库的基本包,而不是使用@EnableJpaRepositories

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM