BAEL-2070 Qualifier used instead of Primary to distinguish between different repository beans
This commit is contained in:
parent
12124f30cb
commit
e3a84dae5b
|
@ -1,13 +1,14 @@
|
||||||
package com.baeldung.dependency.exception.app;
|
package com.baeldung.dependency.exception.app;
|
||||||
|
|
||||||
import com.baeldung.dependency.exception.repository.InventoryRepository;
|
import com.baeldung.dependency.exception.repository.InventoryRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PurchaseDeptService {
|
public class PurchaseDeptService {
|
||||||
private InventoryRepository repository;
|
private InventoryRepository repository;
|
||||||
|
|
||||||
public PurchaseDeptService(InventoryRepository repository) {
|
public PurchaseDeptService(@Qualifier("dresses") InventoryRepository repository) {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
package com.baeldung.dependency.exception.repository;
|
package com.baeldung.dependency.exception.repository;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Primary
|
@Qualifier("dresses")
|
||||||
@Repository
|
@Repository
|
||||||
public class DressRepository implements InventoryRepository {
|
public class DressRepository implements InventoryRepository {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.baeldung.dependency.exception.repository;
|
package com.baeldung.dependency.exception.repository;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Qualifier("shoes")
|
||||||
@Repository
|
@Repository
|
||||||
public class ShoeRepository implements InventoryRepository {
|
public class ShoeRepository implements InventoryRepository {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue