New Springboot Annotation
New Springboot Annotation
Spring includes a lot of annotations. Some are annotations created within Spring. Some are annotations called for by
various Java specifications. The annotations fall into categories, as follows:
Spring Framework
REST
HATEOAS
Session
Boot
Integration
Cloud
Data
Batch
Aspect-oriented Programming
Integration Testing
JMX
Cache Abstraction
Other
Spring Framework
The Spring Framework is the core project within Spring. The Spring Framework includes annotations in the following
categories:
Dependency Injection
Configuration
JMS
AMQP
Bean Lifecycle
MVC/Web
CORS Support
Dependency Injection
@Autowired Widely used dependency injection mechanism for constructors, methods, and interfaces.
A dependency injection mechanism that can replace @Autowired. @Named may also be
@Inject
used in place of @Autowired and @Inject.
A dependency injection mechanism that can replace @Autowired and @Inject. @Named
@Named may also be used in place of @Autowired and @Inject. @Named is also equivalent to
@Component and @ManagedBean.
Injection mechanism for fields and methods that indicates a default value. Often used to
@Value
get values from property files.
Marks a method (typically a JavaBean setter method) as being 'required'. That is, the
@Required
method must be configured to be dependency-injected with a value.
Indicates that a particular bean should be given preference when multiple beans are
@Primary candidates to be autowired to a single-valued dependency. If exactly one 'primary' bean
exists among the candidates, it will be the autowired value.
@Import Allows for loading @Bean definitions from another configuration class.
Indicates 'lookup' methods, to be overridden by the container to redirect them back to the
@Lookup BeanFactory for a getBean call. This is essentially an annotation-based version of the XML
lookup-method attribute.
Configuration
@ComponentScan Configures component scanning directives for use with @Configuration classes.
Indicates that the primary purpose of the annotated class is to provide a source of bean
@Configuration
definitions.
Defines the sort order for an annotated component. Lower values have higher priority.
@Order
@Priority can replace @Order.
Defines the sort order for an annotated component. Lower values have higher priority.
@Priority
@Order can replace @Priority.
Associates a value with a particular argument. More finely tuned way than @Order and
@Qualifier
@Priority to control selection.
@Retention Indicates how long annotations with the annotated type are to be retained.
Indicates that a component is eligible for registration when one or more specified
@Profile
profiles are active.
Indicates that a component is only eligible for registration when all specified conditions
@Conditional
match.
Allows for loading @Bean definitions from another configuration class. Also allows for
@ImportResource
importing XML configuration files.
Specifies that an event listener is asynchronous. See also: Async under Task Execution
@Async
and Scheduling.
JMS
@SendTo Indicates the method (or sometimes class) that responds to a message.
Indicates that the return value of a message-handling method should be sent as a Message to the
@SendToUser specified destination(s) prepended with /user/{username} where the user name is extracted from
the headers of the input message being handled.
AMQP
Defines a queue, the exchange it is to be bound to, and an optional binding key. Used
@QueueBinding
with @RabbitListener .
@Argument Represents an argument used when declaring queues etc within a QueueBinding.
Enable Rabbit listener annotated endpoints that are created behind the scenes by
@EnableRabbit
a RabbitListenerContainerFactory . To be used on @Configuration classes.
marks a method to be the target of a Rabbit message listener within a class that is annotated
@RabbitHandler
with @RabbitListener .
Enables proxying of @RabbitListener beans to capture arguments and results (if any). Used on
@RabbitListenerTest
@Configuration classes.
Bean Lifecycle
Spring’s bean lifecycle management capability includes the following annotations:
For example, @foo will find a bean named foo , provided the evaluation context has been
@{BeanName}
configured with a bean resolver.
Indicates that a method instantiates, configures and initializes a new object to be managed by the
@Bean
Spring IoC container.
Identifies a method to be called after an instance of a bean has been constructed. Used to
@PostConstruct
populate caches and similar operations.
MVC/Web
@SessionAttribute Provides access to pre-existing session attributes that are managed globally.
@ResponseBody Causes the return type to be written to the response body (rather than the model).
@Header Indicates that a method parameter’s value should be retrieved from the message headers.
@RequestBody Binds a method parameter to the value of the HTTP request body.
A specialization of @Scope for a component whose lifecycle is bound to the current web
@RequestScope
request.
A specialization of @Scope for a component whose lifecycle is bound to the current web
@SessionScope
session.
A specialization of @Scope for a component whose lifecycle is bound to the current web
@ApplicationScope
application.
Spring MVC provides the following convenience annotations for request mapping:
CORS Support
Spring MVC/Web includes a single annotation for managing Cross-Origin Resource Support (CORS):
Security
Spring Security provides the following annotations:
@PostAuthorize Performs an access-control check after the method has been invoked.
Enables only the Spring Security TestExecutionListener classes (rather than all
@SecurityTestExecutionListeners
Spring TestExecutionListener classes)
After a method has been called, iterates through a returned collection and
@PostFilter
removes any item that doesn’t match the filter.
Before a method is called, iterates through a collection and removes any item that
@PreFilter
doesn’t match the filter. (Used much more rarely than @PostFilter).
@EnableWebMvcSecurity Enables Spring Security integration with Spring MVC.
Enables configuration for an OAuth2 client in a web application that wants to use
@EhableOAuth2Client
the Authorization Code Grant from one or more OAuth2 Authorization servers.
Spring WebSocket
Spring MVC/Web includes the following annotations for working with WebSockets:
REST
Spring Data REST provides the following annotations:
@RepositoryRestResource Marks a repository for custom export mapping and rel attributes.
@RepositoryEvenHandler Class-level annotation that indicates that the class is an event handler for a repository.
Indicates how a repository should be exported and what the value of the rel attribute in
@RestResource
links will be.
Ties a particular projection type to a source type. Used to find projection interfaces at
@Projection
startup time.
Declares a field as the one representing the principal that created the entity containing
@CreatedBy
the field.
Declares a field as the one representing the date the entity containing the field was
@CreatedDate
created.
Declares a field as the one representing the principal that recently modified the entity
@LastModifiedBy
containing the field.
Declares a field as the one representing the date the entity containing the field was
@LastModifiedDate
recently modified.
Indicates that a constructor, even one that’s package protected, as the primary
@PersistenceConstructor
constructor used by the persistence logic.
Indicates that a field should be persisted even if there are no getter and setter methods
@Persistent
for it.
@ReadOnlyProperty Marks a field as read-only for the mapping framework. The field will not be persisted.
Lets String based type aliases to be used when writing type information
@TypeAlias
for PersistentEntity objects.
Indicates a controller that declares request mappings to be augmented with a base URI
@BasePathAwareController
in the Spring Data REST configuration.
HATEOAS
Spring HATEOAS provides the following annotations:
@EnableHypermediaSupport
Enables support for a particular hypermedia representation type.
@EnableEntityLinks
Enables dependency injection of EntityLinks objects.
@ExposesResourceFor
Class-level annotation for controllers. Indicates which model type the controller manages.
@Relation
Indicates the relation to be used when embedding objects in hypermedia.
Session
Spring Session provides the following annotations:
@EnableRedisHttpSession
Exposes the SessionRepositoryFilter as a bean named "springSessionRepositoryFilter" and backed by Redis. Must be
added to an @Configuration class.
@EnableGemFireHttpSession
Exposes the SessionRepositoryFilter as a bean named "springSessionRepositoryFilter" and backed by Pivotal GemFire
or Apache Geode. Must be added to an @Configuration class.
@EnableJdbcHttpSession
Exposes the SessionRepositoryFilter as a bean named "springSessionRepositoryFilter" and backed by a relational
database. Must be added to an @Configuration class.
@EnableMongoHttpSession
Exposes the SessionRepositoryFilter as a bean named "springSessionRepositoryFilter" and backed by Mongo. Must be
added to an @Configuration class.
@EnableHazelcastHttpSession
Exposes the SessionRepositoryFilter as a bean named "springSessionRepositoryFilter" and backed by Hazelcast. Must
be added to an @Configuration class.
@EnableSpringHttpSession
Exposes the SessionRepositoryFilter as a bean named "springSessionRepositoryFilter" and backed by a user provided
implementation of SessionRepository. Must be added to an @Configuration class.
Boot
Spring Boot provides the following annotations:
@SpringBootApplication
Convenience annotation that includes @Configuration, @EnableAutoConfiguration, and @ComponentScan
@EnableAutoConfiguration
tells Spring Boot to determine how you will want to configure Spring, based on the jar dependencies that you have
added.
@EntityScan
Configures the base packages used by auto-configuration when scanning for entity classes.
@ConfigurationProperties
Identifies a class a configuration properties class, which can then be used to control and validate configuration.
@@EnableConfigurationProperties
Enables support for @ConfigurationProperties annotated beans.
@ConfigurationPropertiesBinding
Qualifier for beans that are needed to configure the binding of ConfigurationProperties (often converters).
@JsonComponent
Provides JsonSerializer and/or JsonDeserializer implementations to be registered with Jackson
when JsonComponentModule is in use.
@ServletComponentScan
Enables automatic registration of classes annotated with @WebServlet, @WebFilter, and @WebListener.
@EnableOAuth2Sso
Enables OAuth2 Single Sign On (SSO).
@SpringBootTest
Creates an ApplicationContext object that supports testing a Spring Boot application.
@AutoConfigureMockMvc
Configures a MockMvc object for use when testing Spring Boot applications.
@SpringBootConfiguration
Indicates that a class provides Spring Boot application @Configuration . Can be used as an alternative to the Spring’s
standard @Configuration annotation so that configuration can be found automatically (for example in tests). An
application should include only one @SpringBootConfiguration, and most idiomatic Spring Boot applications will
inherit it from @SpringBootApplication.
@TestConfiguration
@Configuration that can be used to define additional beans or customizations for a test. Unlike regular
@Configuration classes the use of @TestConfiguration does not prevent auto-detection of
@SpringBootConfiguration.
@LocalServerPort
Annotation at the field or method/constructor parameter level that injects the HTTP port that got allocated at runtime.
Provides a convenient alternative for @Value("${local.server.port}") .
@MockBean
Adds a mock bean to a Spring ApplicationContext .
@Spybean
Applies Mockito spies to a Spring ApplicationContext .
@ImportAutoConfiguration
Imports and applies the specified auto-configuration classes. Sometimes useful for testing. Generally,
@EnableAutoConfiguration should be preferred.
@JsonTest
Auto-configures Jackson ObjectMapper , any @JsonComponent beans and any Jackson Modules .
@WebMvcTest
Used with @RunWith(SpringRunner.class) for a typical Spring MVC test. Can be used when a test focuses only on
Spring MVC components. Using this annotation will disable full auto-configuration and instead apply only
configuration relevant to MVC tests.
@DataJpaTest
Annotation that can be used in combination with @RunWith(SpringRunner.class) for a typical JPA test. Can be used
when a test focuses only on JPA components.
@AutoConfigureTestEntityManager
Can be applied to a test class to enable auto-configuration of a TestEntityManager.
@AutoConfigureTestDatabase
Can be applied to a test class to configure a test database to use instead of any application defined or auto-
configured DataSource.
@JdbcTest
Annotation that can be used in combination with @RunWith(SpringRunner.class) for a typical JDBC test. By default, it
will also configure an in-memory embedded database and a JdbcTemplate .
@DataMongoTest
Used to test MongoDB applications. By default, it will configure an in-memory embedded MongoDB (if available),
configure a MongoTemplate, scan for @Document classes and configure Spring Data MongoDB repositories.
@RestClientTest
Used to test REST clients. By default, it will auto-configure Jackson and GSON support, configure a
RestTemplateBuilder and add support for MockRestServiceServer.
@AutoConfigureRestDocs
Used to use Spring REST Docs in your tests. It will automatically configure MockMvc to use Spring REST Docs and
remove the need for Spring REST Docs' JUnit rule.
@WebIntegrationTest
Test class annotation signifying that the tests are "web integration tests" and therefore require full startup in the same
way as a production application (listening on normal ports). Normally used in conjunction
with @SpringApplicationConfiguration .
@SpringApplicationConfiguration
Class-level annotation that is used to determine how to load and configure an ApplicationContext for integration
tests. Similar to the standard ContextConfiguration but uses Spring Boot’s SpringApplicationContextLoader .
@ConditionalOnClass
Matches only when the specified classes are on the classpath.
@ConditionalOnMissingBean
Matches only when the specified bean classes and/or names are not already contained in the BeanFactory.
@AutoConfigureBefore
Used when configurations need to be loaded in a particular order.
@AutoConfigureAfter
Used when configurations need to be loaded in a particular order.
@AutoconfigureOrder
Allows for ordering certain auto-configurations that shouldn’t have any direct knowledge of each other.
@ConditionalOnProperty
Checks whether the specified properties have the specified value.
@ConditionalOnResource
Lets configuration to be included only when a specific resource is present.
@ConditionalOnWebApplication
Matches only when the application context is a web application
@ConditionalOnNotWebApplication
Matches only when the application context is not a web application.
@ConditionalOnExpression
Lets configuration be included based on the result of a SpEL expression.
@ManagementContextConfiguration
Specialized @Configuration class that defines configuration specific for the management context. Configurations
should be registered in /META-INF/spring.factories under the
org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration key.
@ExportMetricWriter
Qualifier annotation for a metric repository that is to be used to export metrics from the ExportMetricReader readers.
@ExportMetricReader
Qualifier annotation for a metric reader that can be exported (to distinguish it from others that might be installed by
the user for other purposes).
@FlywayDataSource
Specifies a DataSource to be injected into Flyway. If used for a second data source, the other (main) one would
normally be marked as {@code @Primary} .
@LiquibaseDataSource
Specifies a DataSource to be injected into Liquibase. If used for a second data source, the other (main) one would
normally be marked as {@code @Primary} .
@DeprecatedConfigurationProperty
Indicates that a getter in a ConfigurationProperties object is deprecated. This annotation has no bearing on the
actual binding processes, but it is used by the spring-boot-configuration-processor to add deprecation meta-data.
@NestedConfigurationProperty
Indicates that a field in a ConfigurationProperties object should be treated as if it were a nested type.
Integration
Spring integration includes the following annotations:
@EnableIntegration
Enables Spring Integration infrastructure, registers built-in beans, adds BeanFactoryPostProcessors, adds
BeanPostProcessors, and adds annotation processors.
@EnableIntegrationManagement
Enables default configuration of management in Spring Integration components in an existing application.
@EnableMessageHistory
Enables MessageHistory for Integration components.
@EnablePublisher
Provides the registration for the PublisherAnnotationBeanPostProcessor to allow the use of the Publisher annotation.
@IntegrationComponentScan
Configures component scanning directives for use with Configuration classes.
@Publisher
Indicates that a method (or all public methods if applied at class-level) should publish Messages.
@GlobalChannelInterceptor
ChannelInterceptor components with this annotation will be applied as global channel interceptors using the
provided patterns to match channel names.
@Aggregator
Indicates that a method is capable of aggregating messages.
@BridgeFrom
Marks a Bean method for a MessageChannel to produce a BridgeHandler and Consumer Endpoint .
@BridgeTo
Marks a Bean method for a MessageChannel to produce a BridgeHandler and Consumer Endpoint.
@CorrelationStrategy
Indicates that a given method is capable of determining the correlation key of a message sent as parameter.
@Filter
Indicates that a method is capable of playing the role of a Message Filter.
@Gateway
Indicates that an interface method is capable of mapping its parameters to a message or message payload.
@GatewayHeaer
Provides the message header value or expression.
@IdempotentReceiver
A method that has a Messaging annotation ( @code , @ServiceActivator , @Router etc.) that also has this annotation
has an IdempotentReceiverInterceptor applied to the
associated MessageHandler.handleMessage(org.springframework.messaging.Message<?>) method.
@InboundChannelAdapter
Indicates that a method is capable of producing a Message payload.
@IntegrationComponentScan
Configures component scanning directives for use with Configuration classes.
@MessageEndpoint
Stereotype annotation indicating that a class is capable of serving as a Message endpoint.
@MessagingGateway
Provides an Integration Messaging Gateway Proxy (<gateway/>) as an abstraction over the messaging API.
@Payloads
Marks a method parameter as being a list of message payloads, for POJO handlers that deal with lists of messages.
@Poller
Provides the PollerMetadata options for the Messaging annotations for polled endpoints.
@Publisher
Indicates that a method (or all public methods if applied at class-level) should publish Messages.
@ReleaseStrategy
Indicates that a method is capable of asserting if a list of messages or payload objects is complete.
@Role
Assigns endpoints to a role. The assigned endpoints can be started and stopped as a group.
@Router
Indicates that a method is capable of resolving to a channel or channel name based on a message, message header(s),
or both.
@ServiceActivator
Indicates that a method is capable of handling a message or message payload.
@Splitter
Indicates that a method is capable of splitting a single message or message payload to produce multiple messages or
payloads.
@Transformer
Indicates that a method is capable of transforming a message, message header, or message payload.
@IntegrationConverter
Registers Converter , GenericConverter or ConverterFactory beans for the integrationConversionService .
@EnableIntegrationMBeanExport
Enables default exporting for Spring Integration components in an existing application and all @ManagedResource
annotated beans.
@EnableMBeanExport
Enables default exporting of all standard MBeans from the Spring context and all @ManagedResource annotated
beans.
@IntegrationManagedResource
Clone of ManagedResource limiting beans thus annotated so that they will only be exported by the
IntegrationMBeanExporter and prevented from being exported by other MBeanExporters (if present).
@EnableIntegrationGraphController
Enables the IntegrationGraphController if DispatcherServlet is present in the classpath.
Cloud
Spring Cloud includes the following annotations:
@EnableConfigServer Embeds the Spring Cloud Config Server in another Spring application.
@EnableEurekaServer Enables the Netflix Eureka Service Discovery client.
Enables the Hystrix circuit breaker. Must go on an application class (such as a class
@EnableHystrix
marked with @SpringBootApplication).
Indicates that a bean should be wrapped in a proxy that is connected to the Hystrix
@HystrixCommand
circuit breaker.
@HystrixProperty Sets a property for the @HystrixCommand annotation. See the @Hystrix wiki.
@EnableHystrixDashboard Enables the Hystrix dashboard. Must go on a Spring Boot main class.
Enables the Turbine application for a Spring application. Must go on a Spring Boot
@EnableTurbine
main class.
Enables the Turbine Stream application for a Spring application. Must go on a Spring
@EnableTurbineStream
Boot main class.
@FeignClient Declares that a REST client should be created for the specified interface.
Scans for interfaces that declare they are feign clients. Must go on the application
@EnableFeignCLients
class.
Sets up a Zuul server endpoint and installs some reverse proxy filters in it, so it can
@EnableZuulProxy forward requests to backend servers. The backends can be registered manually
through configuration or via a DiscoveryClient .
Enables the binding of targets annotated with Input and Output to a broker,
@EnableBinding
according to the list of interfaces passed as value to the annotation.
@StreamListener Indicates a method that is a listener to the inputs declared through @EnableBinding .
@Input Indicates that an input binding target will be created by the framework.
@Output Indicates that an output binding target will be created by the framework.
@EnableRxJavaProcessor Class annotation that identifies the class as an RxJava processor module.
@EnableZipkinStreamServer Enables transporting of spans over a Spring Cloud Stream (such as RabbitMQ).
Data
Spring includes the following annotations:
Class-level annotation that enables JPA repositories. By default, scans the package o
@EnableJpaRepositories
Spring Data repositories.
Marks a property to be considered when doing a full-text search. Important: The pro
@TextScore
saved.
@EntityGraph Configures the JPA 2.1 EntityGraphs that should be used on repository methods.
Indicates a method that publishes domain events. A method marked with @AfterDom
@DomainEvents
manipulated the published events.
Indicates a method that manipulates published domain events (often for selecting o
@AfterDomainEventPublication
criterion).
@SortDefault Defines the default Sort options to be used when injecting a Sort instance into a con
@ProjectedPayload Enables projection and projection method annotations that contain JSON or XPath e
@Procedure Declares a JPA 2.1 stored procedure mapping directly on a repository method.
Batch
Spring Batch includes the following annotations:
@AfterChunk
Marks a method to be called after a chunk is executed.
@AfterChunkError
Marks a method to be called after a has failed and been marked for rollback.
@AfterJob
Marks a method to be called after a Job has completed.
@AfterProcess
Marks a method to be called after an item is passed to an ItemProcessor .
@AfterRead
Marks a method to be called after an item is read from an ItemReader .
@AfterStep
Marks a method to be called after a Step has completed.
@AfterWrite
Marks a method to be called after an item is passed to an ItemWriter .
@BeforeChunk
Marks a method to be called before a chunk is executed.
@BeforeJob
Marks a method to be called before a Job is executed, which comes after a JobExecution is created and persisted,
but before the first Step is executed.
@BeforeProcess
Marks a method to be called before an item is passed to an ItemProcessor .
@BeforeRead
Marks a method to be called before an item is read from an ItemReader .
@BeforeStep
Marks a method to be called before a Step is executed, which comes after a StepExecution is created and persisted,
but before the first item is read.
@BeforeWrite
Marks a method to be called before an item is passed to an ItemWriter .
@OnProcessError
Marks a method to be called if an exception is thrown by an ItemProcessor .
@OnReadError
Marks a method to be called if an exception is thrown by an ItemReader .
@OnSkipInProcess
Marks a method to be called when an item is skipped due to an exception thrown in the ItemProcessor .
@OnSkipInRead
Marks a method to be called when an item is skipped due to an exception thrown in the ItemReader .
@OnSkipInWrite
Marks a method to be called when an item is skipped due to an exception thrown in the ItemWriter .
@OnWriteError
Marks a method to be called if an exception is thrown by an ItemWriter .
@EnableBatchProcessing
Enable Spring Batch features and provide a base configuration for setting up batch jobs in an @Configuration class,
roughly equivalent to using the <batch:*> XML namespace.
@JobScope
Convenience annotation for job-scoped beans that defaults the proxy mode, so that it doesn’t have to be specified
explicitly on every bean definition.
@StepScope
Convenience annotation for step-scoped beans that defaults the proxy mode, so that it doesn’t have to be specified
explicitly on every bean definition.
@Classifier
Mark a method as capable of classifying its input to an instance of its output.
Aspect-oriented Programming
Spring includes a set of annotations for working with Aspect-oriented Programming (AOP):
Enables support for handling components marked with AspectJ’s @Aspect annotation.
@EnableAspectJAutoProxy Must be used on a class that is also marked with the @Configuration annotation (or
another annotation that includes the @Configuration annotation).
Limits matching to join points. (Not to be confused with @Target for @Configuration
@target
classes.)
@within Limits matching to join points within types that have the given annotation.
limits matching to join points where the subject of the join point has the given
@annotation
annotation
Class annotation that specifies the default transaction semantics for the execution of
@Transactional
any public operation in the class.
@Before Declares pointcut advice that should run before methods matched by the pointcut.
Declares pointcut advice that should run after the methods matched by the pointcut.
@AfterReturning
The methods must return normally. See @AfterThrowing and @After.
Declares pointcut advice that should run after the methods matched by the pointcut
@AfterThrowing
have thrown an exception.
Declares pointcut advice to run after the methods matched by the pointcut have run,
@After whether they returned normally or threw an exception. Parallel to finally in a try-
catch-finally block.
Declares advice that runs around (potentially both before and after) the methods
@Around matched by the pointcut. Can also determine if pointcut methods run. Do not use if
@Before or @After suffice.
Integration Testing
Spring includes a set of annotations for working with integration testing:
Class-level annotation that is used to declare that the ApplicationContext loaded for an
@WebAppConfiguration
integration test should be a WebApplicationContext .
@ContextHierarchy Class-level annotation that defines a hierarchy of ApplicationContexts for integration tests.
@ActiveProfiles Class-level annotation that indicates which bean definition profiles should be active.
Class-level annotation that configures the locations of properties files and inlined
@TestPropertySource properties to be added to the set of PropertySources in the Environment for an
ApplicationContext loaded for an integration test.
Indicates that the underlying Spring ApplicationContext has been modified or corrupted
@DirtiesContext in some manner during the execution of a test and should be closed. When an application
context is marked as dirty, it is removed from the testing framework’s cache and closed.
Causes a transaction to commit rather than rollback during testing. Use only when you
@Commit
want a test to modify a database. See @Rollback.
indicates whether the transaction for a transactional test method should be rolled back
@Rollback
after the test method has completed. See @Commit.
Indicates that the annotated void method should be executed before a transaction is
@BeforeTransaction started for test methods configured to run within a transaction via
Spring’s @Transactional annotation.
Indicates that the annotated void method should be executed after a transaction is ended
@AfterTransaction for test methods configured to run within a transaction via
Spring’s @Transactional annotation.
Annotates a test class or test method to configure SQL scripts to be executed against a
@Sql
given database during integration tests.
Defines metadata that is used to determine how to parse and execute SQL scripts
@SqlConfig
configured via the @Sql annotation.
Unit Testing
Spring includes a set of annotations for unit testing:
Indicates that, if the value returned by the name argument matches the value of
@IfProfileValue the value argument, the annotated test is enabled for a specific testing
environment.
Indicates that the annotated test method must finish execution in a specified
@Timed
time period (in milliseconds).
@Repeat Indicates that the annotated test method must be executed a number of times.
JMX
Spring includes a set of annotations for working with Java Managed Extensions (JMX):
Cache Abstraction
Spring includes a set of annotations for working with caching:
@CacheEvict Indicates that a method performs cache eviction (removes items from a cache).
Allows multiple nested @Cacheable , @CachePut and @CacheEvict to be used on the same
@Caching
method
Class-level annotation that allows sharing of the cache names, the custom KeyGenerator, the
@CacheConfig custom CacheManager, and the custom CacheResolver. Placing this annotation on the class
does not turn on any caching operation. See @EnableCaching.
Similar to @Cacheable but can cache specific exceptions and force the execution of the method
@CacheResult
regardless of the content of the cache.
@CacheRemove Similar to @CacheEvict but can support conditional removal if the method throws an exception.
@CacheValue Usable with @CachePut to update the cache before or after method invocation.
Optional method parameter annotation to indicate which argument(s) should be the key. (The
@CacheKey default is to construct the key from all the parameters, unless one or more parameters are
marked with @CacheKey .)
Other
Spring includes a few other annotations that don’t fit into the preceding categories:
@ExceptionHandler Annotation for handling exceptions in specific handler classes and/or handler methods.