If the populateTypes
reference data is not required for all views you may be best to remove the annotated populateTypes()
method and just add the data when it is required - by adding it to the ModelAndView
s of the specific @RequestMapping
methods that need it.
So if you have a @RequestMapping
method called foo()
that has a view that does need the data, then you could do something like:
@RequestMapping(value = "/foo", method = RequestMethod.GET)
public ModelAndView foo() {
ModelAndView modelAndView = new ModelAndView("fooView");
modelAndView.addObject("types", typeRepository.findAll());
return modelAndView;
}