Mongo 自定义存储库命名问题
Mongo custom repository naming problems
我有定义:
public interface FruitsRepository extends MongoRepository<Fruits, String>, FruitsRepositoryCustom {
...
}
public interface FruitsRepositoryCustom {
...
}
public class FruitsRepositoryImpl implements FruitsRepositoryCustom {
...
}
当我尝试将 FruitsRepositoryImpl
的名称更改为 FruitsRepositoryXImpl
时,spring 无法识别它并且出现异常。这是什么原因?如何更改通过自定义接口实现的 class 的名称?
自定义存储库实现名称后缀默认为 Impl
。
要将其更改为 XImpl
,您应该更改 repositories
元素的 repository-impl-postfix
属性。例如:
<repositories repository-impl-postfix="XImpl" base-package=...>
或使用 Java:
@EnableMongoRepositories(repositoryImplementationPostfix="Ximpl" basePackages=...)
但是请注意,更改后缀名称适用于所有自定义存储库。
查看更多
我有定义:
public interface FruitsRepository extends MongoRepository<Fruits, String>, FruitsRepositoryCustom {
...
}
public interface FruitsRepositoryCustom {
...
}
public class FruitsRepositoryImpl implements FruitsRepositoryCustom {
...
}
当我尝试将 FruitsRepositoryImpl
的名称更改为 FruitsRepositoryXImpl
时,spring 无法识别它并且出现异常。这是什么原因?如何更改通过自定义接口实现的 class 的名称?
自定义存储库实现名称后缀默认为 Impl
。
要将其更改为 XImpl
,您应该更改 repositories
元素的 repository-impl-postfix
属性。例如:
<repositories repository-impl-postfix="XImpl" base-package=...>
或使用 Java:
@EnableMongoRepositories(repositoryImplementationPostfix="Ximpl" basePackages=...)
但是请注意,更改后缀名称适用于所有自定义存储库。
查看更多