@@ -649,11 +649,13 @@ If you use namespace configuration, the repository infrastructure tries to autod
|
||||
|
||||
The first configuration example will try to look up a class `com.acme.repository.UserRepositoryImpl` to act as custom repository implementation, whereas the second example will try to lookup `com.acme.repository.UserRepositoryFooBar`.
|
||||
|
||||
[[repositories.single-repository-behaviour.ambiguity]]
|
||||
===== Resolution of ambiguity
|
||||
|
||||
If multiple implementations with matching class names get found in different packages Spring Data uses the bean names to identify the correct one to use.
|
||||
If multiple implementations with matching class names get found in different packages, Spring Data uses the bean names to identify the correct one to use.
|
||||
|
||||
Given the following two custom implementations for the `UserRepository` introduced above the first implementation will get picked. Its bean name is `userRepositoryImpl` matches that of the repository interface (`userRepository`) plus the postfix `Impl`.
|
||||
Given the following two custom implementations for the `UserRepository` introduced above the first implementation will get picked.
|
||||
Its bean name is `userRepositoryImpl` matches that of the repository interface (`userRepository`) plus the postfix `Impl`.
|
||||
|
||||
.Resolution of amibiguous implementations
|
||||
====
|
||||
@@ -678,7 +680,7 @@ class UserRepositoryImpl implements UserRepositoryCustom {
|
||||
----
|
||||
====
|
||||
|
||||
If you annotate the `UserRepository` interface with `Component("specialCustom")' the bean name plus `Impl` matches that of the second Repository and it will be picked instead of the first one.
|
||||
If you annotate the `UserRepository` interface with `@Component("specialCustom")` the bean name plus `Impl` matches the one defined for the repository implementation in `com.acme.impl.two` and it will be picked instead of the first one.
|
||||
|
||||
===== Manual wiring
|
||||
|
||||
|
||||
Reference in New Issue
Block a user