BAEL-2070 Qualifier used instead of Primary (#5205)

* BAEL-2070 Qualifier used instead of Primary to distinguish between different repository beans

* BAEL-2095 CrudRepository save() method

* (REVERT) BAEL-2095 CrudRepository save() method
This commit is contained in:
xamcross 2018-09-11 06:43:06 +03:00 committed by Grzegorz Piwowarek
parent 50f0d57182
commit ba32ee32c6
3 changed files with 6 additions and 2 deletions

View File

@ -1,13 +1,14 @@
package com.baeldung.dependency.exception.app;
import com.baeldung.dependency.exception.repository.InventoryRepository;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@Service
public class PurchaseDeptService {
private InventoryRepository repository;
public PurchaseDeptService(InventoryRepository repository) {
public PurchaseDeptService(@Qualifier("dresses") InventoryRepository repository) {
this.repository = repository;
}
}

View File

@ -1,9 +1,10 @@
package com.baeldung.dependency.exception.repository;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;
@Primary
@Qualifier("dresses")
@Repository
public class DressRepository implements InventoryRepository {
}

View File

@ -1,7 +1,9 @@
package com.baeldung.dependency.exception.repository;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
@Qualifier("shoes")
@Repository
public class ShoeRepository implements InventoryRepository {
}