0

我有定义:

public interface  FruitsRepository extends MongoRepository<Fruits, String>,  FruitsRepositoryCustom {
...
}

public interface  FruitsRepositoryCustom {
...
}

public class FruitsRepositoryImpl implements  FruitsRepositoryCustom {
...
}

当我尝试将名称更改为 FruitsRepositoryImplto FruitsRepositoryXImpl它时,spring 无法识别它,并且我遇到了异常。这是什么原因,如何更改通过自定义接口实现的类的名称?

4

1 回答 1

1

默认情况下,自定义存储库实现名称后缀Impl

为了将其更改为XImpl您应该更改元素的repository-impl-postfix属性。repositories例如:

<repositories repository-impl-postfix="XImpl" base-package=...>

或者通过使用 Java:

@EnableMongoRepositories(repositoryImplementationPostfix="Ximpl" basePackages=...)

但是,请注意更改后缀名称适用于所有自定义存储库。

在参考文档、命名空间参考中查看更多信息

于 2015-08-18T08:37:32.723 回答