My controller:
@RestController
@RequestMapping("/mypath")
public class MyController {
@Autowired
MyServiceInterface service;
@PostMapping("/{source}")
void myControllerFunc(@PathVariable String source, @RequestBody MyObject obj) {
...
Object myServiceObj = service.myServiceFunc(param);
...
}
}
My Service Interface:
public interface MyServiceInterface {
Object myServiceFunc(String param);
}
My Service Implemantations:
@Service
public class MyServiceOne {
Object myServiceFunc(String param) {
...
}
}
@Service
public class MyServiceTwo {
void myServiceFunc(String param) {
...
}
}
My spring-boot version : 1.5.7
I want to inject the service according to my path variable ("source") . If source = one, inject MyServiceOne or if source = two, inject MyServiceTwo.
Is this possible?