Version 4.3 included a number of improvements, as described in the following sections:
@Autowired
annotation if the target
bean only defines one constructor.
@Configuration
classes support constructor injection.
condition
of an @EventListener
can
now refer to beans (e.g. @beanName.method()
).
String[] path
attribute of @RequestMapping
can be overridden with
String path
in a composed annotation.
@PersistenceContext
/@PersistenceUnit
selects a primary EntityManagerFactory
bean if declared as such.
@Scheduled
and @Schedules
may now be used as meta-annotations to create
custom composed annotations with attribute overrides.
@Scheduled
is properly supported on beans of any scope.
jdbc:initialize-database
and jdbc:embedded-database
support 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
the new 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:
@beanName.method()
).
ConcurrentMapCacheManager
and ConcurrentMapCache
now support the serialization
of cache entries via a new storeByValue
attribute.
@Cacheable
, @CacheEvict
, @CachePut
, and @Caching
may now be used as
meta-annotations to create custom composed annotations with attribute overrides.
@SendTo
can now be specified at the class level to share a common reply destination.
@JmsListener
and @JmsListeners
may now be used as meta-annotations to create
custom composed annotations with attribute overrides.
New @GetMapping
, @PostMapping
, @PutMapping
, @DeleteMapping
, and @PatchMapping
composed annotations for @RequestMapping
.
New @RequestScope
, @SessionScope
, and @ApplicationScope
composed annotations
for web scopes.
@RestControllerAdvice
annotation with combined @ControllerAdvice
with @ResponseBody
semantics.
@ResponseStatus
is now supported at the class level and inherited by all methods.
@SessionAttribute
annotation for access to session attributes (see example).
@RequestAttribute
annotation for access to request attributes (see example).
@ModelAttribute
allows preventing data binding via binding=false
attribute (see reference).
@PathVariable
may be declared as optional (for use on @ModelAttribute
methods).
ContentNegotiationManager
for media type determination.
RestTemplate
and AsyncRestTemplate
support strict URI variable encoding via DefaultUriTemplateHandler
.
AsyncRestTemplate
supports request interception.
@SendTo
and @SendToUser
can now be specified at class-level to share a common destination.
SpringRunner
alias for the SpringJUnit4ClassRunner
.
@ContextConfiguration
can now be completely omitted if default
XML files, Groovy scripts, or @Configuration
classes are detected.
@Transactional
test methods are no longer required to be public
(e.g., in TestNG and JUnit 5).
@BeforeTransaction
and @AfterTransaction
methods are no longer required to be public
and may now be declared on Java 8 based interface default methods.
ApplicationContext
cache 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
spring.test.context.cache.maxSize
.
ContextCustomizer
API for customizing a test ApplicationContext
after 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 ContextLoader
.
@Sql
and @SqlGroup
may now be used as meta-annotations to create custom composed
annotations with attribute overrides.
ReflectionTestUtils
now 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
in spring-core.jar
.