The concept is we can create a spring application without having XML files so please point to some solution of this using java config file
I am working on creating a sample web mvc application as a proof of concept I am having issue where once the form is submitted I cannot submit again using the form . It gives this error
GenericApplicationContext does not support multiple refresh attempts: just call 'refresh' once
I can see where my issue is but I cant seem to find a work around
Controller.java
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
//@TODO hibernate broke validity
//@TODO disable submit until data is valid
@RequestMapping(value="form", method=RequestMethod.POST)
public String submitForm(@ModelAttribute @Valid Subscriber subscriber,BindingResult result, Model m) {
m.addAttribute("message", "Successfully saved person: " + subscriber.toString());
ctx.register(WebConfiguration.class);
//@TODO fix refresher only once issue
ctx.refresh();
SubscriberDao sao = ctx.getBean(SubscriberDao.class);
sao.savePerson(subscriber);
return "formPage";
}
If you look here ctx.refresh gets called everytime I go to the URL. I tried putting it in a constructor but that did not work.Can anyone help me find a solution/Better alternative if this is wrong.