after migrating from spring 3 to 5 i can’t do this anymore in a rest controller:
@Lazy
@Controller
@RequestMapping("/Portability4CtRestService")
public class Portability4CtRestService extends AbstractP4CtRestService {
private P4CtAccountRoutingService accountRoutingService;
/**
* @param accountRoutingService the accountRoutingService to set
*/
@Autowired
public void setAccountRoutingService(P4CtAccountRoutingService p4ctAccountRoutingService) {
this.accountRoutingService = p4ctAccountRoutingService;
}
@RequestMapping(value = "/searchAccountRouting", method = RequestMethod.POST, consumes = { "application/json" }, produces = { "application/json" })
public @ResponseBody
String searchAccountRouting(HttpServletRequest request) {
//do something with accountRoutingService....
}
}
the objet autowired with @Autowired annotation is always null, the same happens if i use
@Autowired
private P4CtAccountRoutingService accountRoutingService;
or
@Resources
private P4CtAccountRoutingService accountRoutingService;
A possible workaround is to make something like this in the costructor:
public Portability4CtRestService() {
setAccountRoutingService((P4CtAccountRoutingService) it.vtfinance.vtpie.core.configuration.spring.ContextSupport.getContext().getBean(P4CtAccountRoutingService.BEAN_NAME));
}
But i wondering if this is the right way and why i can’t use anymore spring annotation to call a spring bean.