我无法从下面代码中提到的HappyFortuneService类的getDailyForutune()方法中获取sysout。 你能帮我哪里错
预先感谢
公共界面教练{
public String getDailyWorkout() ;
public String getDailyFortune();
}
公共接口FortuneService {
public String getForutune();
public String getDailyForutune();
}
@Component 公共类TennisCoach实现了教练{
private FortuneService fortuneService;
public TennisCoach() {
System.out.println(">>Inside default Constructor");
}
@Autowired
public void setFortuneService(FortuneService fortuneService) {
System.out.println("Inside setFortuneService method");
this.fortuneService = fortuneService;
}
/*@Autowired
public TennisCoach(FortuneService theFortuneService) {
fortuneService=theFortuneService;
}*/
@Override
public String getDailyWorkout() {
// TODO Auto-generated method stub
return "Practise daily elbow workout";
}
@Override
public String getDailyFortune() {
// TODO Auto-generated method stub
fortuneService.getDailyForutune();
return fortuneService.getForutune();
}
}
@Component 公共类HappyFortuneService实现FortuneService {
@Override
public String getForutune() {
// TODO Auto-generated method stub
return "Today is your lucky day";
}
@Override
public String getDailyForutune() {
// TODO Auto-generated method stub
return "Daily Fortune not available";
}
}
公共类AnnotationDemoApp {
public static void main(String[] args) {
//read spring config file
ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("AppContext.xml");
//get the bean from spring container
Coach theCoach=context.getBean("tennisCoach",Coach.class);
//call a method on the bean
System.out.println("method:"+theCoach.getDailyWorkout());
System.out.println("another Method:"+theCoach.getDailyFortune());
//close the context
context.close();
}
}