Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package guru.springframework.sfgdi.controllers;

import guru.springframework.sfgdi.services.PetService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

/**
* Created by jt on 12/28/19.
*/
@Controller
public class PetController {

private final PetService petService;

public String whichPetIsTheBest(){
public PetController(@Qualifier("petChooserService") PetService petService) {
this.petService = petService;
}

public String whichPetIsTheBest() {
return petService.getPetType();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package guru.springframework.sfgdi.services;

import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

/**
* Created by jt on 12/28/19.
*/
@Service("cat")
@Profile("cat")
@Service("petChooserService")
public class CatPetService implements PetService {
@Override
public String getPetType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package guru.springframework.sfgdi.services;

import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

/**
* Created by jt on 12/28/19.
*/
@Profile({"dog", "default"})
public class DogPetService {
@Profile({"dog","default"})
@Service("petChooserService")
public class DogPetService implements PetService {
@Override
public String getPetType(){
return "Dogs are the best!";
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#spring.profiles.active=EN
spring.profiles.active=cat, EN