@Component
@Qualifier("SUCCESS")
public class RandomServiceSuccess implements RandomService{
public String doStuff(){
return "success";
}
}
@Component
@Qualifier("ERROR")
public class RandomServiceError implements RandomService{
public String doStuff(){
throw new Exception();
}
}
调用代码
@Controller
public class RandomConroller {
@Autowired
private RandomService service;
public String do(){
service.doStuff();
}
}
我需要在这里做的是让它们根据可以从 http 请求的一些自定义 http 标头中检索的值进行交换。谢谢!