Skip to content

Commit

Permalink
fixing DI problems for assignment review
Browse files Browse the repository at this point in the history
  • Loading branch information
springframeworkguru committed Dec 28, 2019
1 parent e3d002f commit 6508c2a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package guru.springframework.sfgdi.controllers;

import guru.springframework.sfgdi.services.PetService;
import org.springframework.stereotype.Controller;

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

private final PetService petService;

public PetController(PetService petService) {
this.petService = petService;
}

public String whichPetIsTheBest(){
return petService.getPetType();
}
Expand Down
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")
@Service
@Profile("cat")
public class CatPetService implements PetService {
@Override
public String getPetType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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 {
@Service
public class DogPetService implements PetService {
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

0 comments on commit 6508c2a

Please sign in to comment.