在我试图做以下工作时,我在普伦·姆博克有一个叫马普车控制员班,这个班子即时叫外派,我无法在这个班子内使用依赖注射,例如,如果我试图使用这种注射。
@Resource(name = "savedsearchesService")
private SavedSearchesService savedsearchesService;
我获得一个无名例外。 我不得不通过<代码>SavedSearches Service Savesearchesservice,从我的控制器法到其他外部方法,以便使其得以工作。
I m wondering if anyone can point out why it is this way as I am curious and if there is something I am missing as far as how to do this properly. Thanks
@Controller
@RequestMapping("")
public class MainController {
@Resource(name = "savedsearchesService")
private SavedSearchesService savedsearchesService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String getPersons(Model model, HttpServletRequest request)
throws IOException {
HttpSession session = request.getSession();
SomeExternalClass someExternalClass = new SomeExternalClass ();
someExternalClass.Main();
}
}
外部类别的例子如下:
public class SomeExternalClass {
@Resource(name = "savedsearchesService")
private SavedSearchesService savedsearchesService;
public void Main () {
savedsearchesService.get();
}
}