Get ahead
VMware offers training and certification to turbo-charge your progress.
Learn moreWe are happy to announce the availability of the fourth milestone of Spring Framework 6.2. We shipped quite a few features since our last M3 release.
Spring Framework 6.2.0-M4 is available from repo.spring.io/milestone now, check out the detailed release notes for this version.
The Task
and ScheduledTask
types now expose metadata about their execution: last execution time and outcome, next scheduled execution time...
We also made further refinements for the new @TestBean
and @MockitoBean
support. You can read our reference documentation to see this feature in action.
@ExceptionHandler
methods are now more flexible as they support content negotiation during the error handling phase. This means that you can tailor error handling depending on the content type requested by the HTTP client.
Here's a code snippet showing this feature in action:
@ExceptionHandler(produces = "application/json")
public ResponseEntity<ErrorMessage> handleJson(IllegalArgumentException exc) {
return ResponseEntity.badRequest().body(new ErrorMessage(exc.getMessage(), 42));
}
@ExceptionHandler(produces = "text/html")
public String handle(IllegalArgumentException exc, Model model) {
model.addAttribute("error", new ErrorMessage(exc.getMessage(), 42));
return "errorView";
}
Here, automated clients will get a JSON response, while browsers will display an HTML error page with custom messages.
The community requested the following enhancements - and they're now available!
RestClient
now supports request attributes - a popular request from the community.@ModelAttribute
controller method arguments.Check out our What's New page for details about the new features available at this point.