Spring 4.1 introduces a much simpler infrastructure to register JMS
listener endpoints by annotating bean methods with
The XML namespace has been enhanced to support this new style (
and it is also possible to fully configure the infrastructure using Java config
JmsListenerContainerFactory). It is also possible to register listener endpoints
Spring 4.1 also aligns its JMS support to allow you to benefit from the
abstraction introduced in 4.0, that is:
@SendTo. It is also possible to use a standard
Messagein lieu of
javax.jms.Messageas method argument.
JmsMessageOperationsinterface is available and permits
JmsTemplatelike operations using the
Finally, Spring 4.1 provides additional miscellaneous improvements:
Spring 4.1 supports JCache (JSR-107) annotations using Spring’s existing cache configuration and infrastructure abstraction; no changes are required to use the standard annotations.
Spring 4.1 also improves its own caching abstraction significantly:
CacheResolver. As a result the
valueargument defining the cache name(s) to use is no longer mandatory.
@CacheConfigclass-level annotation allows common settings to be shared at the class level without enabling any cache operation.
Spring 4.1 also has a breaking change in the
CacheInterface as a new
method has been added.
ResourceHttpRequestHandlerhas been expanded with new abstractions
ResourceUrlProvider. A number of built-in implementations provide support for versioned resource URLs (for effective HTTP caching), locating gzipped resources, generating an HTML 5 AppCache manifests, and more. See Section 17.16.7, “Serving of Resources”.
java.util.Optionalis now supported for
@MatrixVariablecontroller method arguments.
ListenableFutureis supported as a return value alternative to
DeferredResultwhere an underlying service (or perhaps a call to
AsyncRestTemplate) already returns
@ModelAttributemethods are now invoked in an order that respects inter-dependencies. See SPR-6299.
@JsonViewis supported directly on
ResponseEntitycontroller methods for serializing different amounts of detail for the same POJO (e.g. summary vs. detail page). This is also supported with View-based rendering by adding the serialization view type as a model attribute under a special key. See the section called “Jackson Serialization View Support” for details.
ResponseEntitymethods just after the controller method returns and before the response is written. To take advantage declare an
@ControllerAdvicebean that implements
ResponseBodyAdvice. The built-in support for
@JsonViewand JSONP take advantage of this. See Section 17.4.1, “Intercepting requests with a HandlerInterceptor”.
There are three new
<mvc:annotation-driven/>, this is used by default instead of JAXB2 if
jackson-dataformat-xmlis in the classpath.
@RequestMapping. For example
handleFoois named "FC#handleFoo". The naming strategy is pluggable. It is also possible to name an
@RequestMappingexplicitly through its name attribute. A new
mvcUrlfunction in the Spring JSP tag library makes this easy to use in JSP pages. See Section 17.7.2, “Building URIs to Controllers and methods from views”.
ResponseEntityprovides a builder-style API to guide controller methods towards the preparation of server-side responses, e.g.
RequestEntityis a new type that provides a builder-style API to guide client-side REST code towards the preparation of HTTP requests.
MVC Java config and XML namespace:
ViewResolverand ‘View’ implementations.
SockJsClientand classes in same package.
SessionUnubscribeEventpublished when STOMP clients subscribe and unsubscribe.
@SendToUsercan target only a single session and does not require an authenticated user.
@MessageMappingmethods can use dot "." instead of slash "/" as path separator. See SPR-11660.
Groovy scripts can now be used to configure the
ApplicationContext loaded for
integration tests in the TestContext framework.
Test-managed transactions can now be programmatically started and ended within
transactional test methods via the new
SQL script execution can now be configured declaratively via the new
@SqlConfig annotations on a per-class or per-method basis.
Test property sources which automatically override system and application property
sources can be configured via the new
TestExecutionListeners can now be automatically discovered.
TestExecutionListeners can now be automatically merged with the default
The documentation for transactional testing support in the TestContext framework has been improved with more thorough explanations and additional examples.
MockHttpServletRequest, and other Servlet API mocks.
AssertThrowshas been refactored to support
MockMvcBuilderrecipes can now be created with the help of
MockMvcConfigurer. This was added to make it easy to apply Spring Security setup but can be used to encapsulate common setup for any 3rd party framework or within a project.
MockRestServiceServernow supports the
AsyncRestTemplatefor client-side testing.