Version 4.3 included a number of improvements, as described in the following sections:
@Autowiredannotation if the target bean only defines one constructor.
@Configurationclasses support constructor injection.
@EventListenercan now refer to beans (e.g.
String pathattribute of
@RequestMappingcan be overridden with
String pathin a composed annotation.
@PersistenceUnitselects a primary
EntityManagerFactorybean if declared as such.
@Schedulesmay now be used as meta-annotations to create custom composed annotations with attribute overrides.
@Scheduledis properly supported on beans of any scope.
jdbc:embedded-databasesupport a configurable separator to be applied to each script.
Spring 4.3 allows concurrent calls on a given key to be synchronized so that the
value is only computed once. This is an opt-in feature that should be enabled via
sync attribute on
@Cacheable. This features introduces a breaking
change in the
Cache interface as a
get(Object key, Callable<T> valueLoader)
method has been added.
Spring 4.3 also improves the caching abstraction as follows:
ConcurrentMapCachenow support the serialization of cache entries via a new
@Cachingmay now be used as meta-annotations to create custom composed annotations with attribute overrides.
@SendTocan now be specified at the class level to share a common reply destination.
@JmsListenersmay now be used as meta-annotations to create custom composed annotations with attribute overrides.
composed annotations for
@ApplicationScope composed annotations
for web scopes.
@RestControllerAdviceannotation with combined
@ResponseStatusis now supported at the class level and inherited by all methods.
@SessionAttributeannotation for access to session attributes (see example).
@RequestAttributeannotation for access to request attributes (see example).
@ModelAttributeallows preventing data binding via
binding=falseattribute (see reference).
@PathVariablemay be declared as optional (for use on
ContentNegotiationManagerfor media type determination.
AsyncRestTemplatesupport strict URI variable encoding via
AsyncRestTemplatesupports request interception.
@SendToUsercan now be specified at class-level to share a common destination.
SpringRunneralias for the
@ContextConfigurationcan now be completely omitted if default XML files, Groovy scripts, or
@Configurationclasses are detected.
@Transactionaltest methods are no longer required to be
public(e.g., in TestNG and JUnit 5).
@AfterTransactionmethods are no longer required to be
publicand may now be declared on Java 8 based interface default methods.
ApplicationContextcache in the Spring TestContext Framework is now bounded with a default maximum size of 32 and a least recently used eviction policy. The maximum size can be configured by setting a JVM system property or Spring property called
ContextCustomizerAPI for customizing a test
ApplicationContextafter bean definitions have been loaded into the context but before the context has been refreshed. Customizers can be registered globally by third parties, foregoing the need to implement a custom
@SqlGroupmay now be used as meta-annotations to create custom composed annotations with attribute overrides.
ReflectionTestUtilsnow automatically unwraps proxies when setting or getting a field.
Furthermore, Spring Framework 4.3 embeds the updated ASM 5.1, CGLIB 3.2.4, and Objenesis 2.4