Spring annotation-driven programming to

SpringFramework two cores, IOC (Inversion of control) controls inversion and DI (Dependency Inject) dependency injection, which concept is respected application should not be directly controlled manner java code dependencies, but managed by the container.

Spring Framework 1.x annotation-driven age of enlightenment

Starting Spring Framework 1.2.0 version began to support Annotation, although levels have support framework @Transactional @managedResource and so on, but the main thing is to XML configuration takes effect.

Spring Framework 2.X annotation-driven era of transition

Spring Framework 2.0 support in Annotation added a new member, @ Required, @Repository and data related to AOP related @Aspect etc., but at the same time enhance the ability to configure XML, or "extensible written in XML (Extensible XML authoring)" of course, the emergence of this expansion capacity, potentially increasing the stakes for the XML configuration.

Framework the Spring  2.5 began, introduced a new skeleton Annotation.

  • @Service
  • @Controller,@RequestMapping及@ModelAttribute

Spring Framework 2.5 also supports the JSR-250 (Java Specification).

@Resource injection

Alternatively @PostConstruct <bean init-method = "..." />

@PreDestroy 替代<bean destroy-method=”…”/>

Although the Spring Framework 2.X era provides a large number of comments, but not many programming tools, the main reason is that the framework level has not "directly" provide Spring application context-driven annotation, and still need XML driven, < context: annotation-config> and <context: component-scan>

Spring Framework 3.x annotation-driven Golden Age

Spring Framework3.x is a landmark era, in addition to enhancing Spring 3.0 annotation mode "derivative" of the hierarchy, the first task is to replace the XML configuration, introduction configuration class notes @Configuration, the annotations are built @Component "derivative "Notes, unfortunately, 3.0 does not introduce <context: component-scan> comment, choosing instead to transition program - @ ImportResource and @Import. ImportResource responsible for importing legacy XML configuration file, Import allows the import of one or more class as a Spring Bean.

3.0 introduces a replacement before age ApplicationContext most of AnnotationConfigApplicationContext. 3.1 introduced new comment @ComponentScan, replace the XML <context: component-scan>, become a big step fully into the annotation-driven era.

SpringFramework3.x Notes upgrade also reflected in the following aspects:

  • The definition statement, @ Bean allowed to set its role comment @Role
  • Spring application context such that the ability of the conditions defined Bean
  • Aspects, @ RequestHeader, @ CookieVale and @RequestPart appear, making it unnecessary to use the Servlet API
  • And configure the properties of the source abstract PropertySources, laid the foundation SpringBoot externalized configuration.
  • Caching and supporting notes Cacheable greatly simplify the development of data cache.
  • Asynchronous @Schedule period and asynchronous web request DeferredResult .

Spring Framework 4.x annotation-driven sound era

3.1 Start provides @Profile provide conditions of an assembled configuration, but this connection is relatively simple, starting 4.0, introduction conditions annotation @Conditional, Condition achieved with custom, short version conditioned plate assembly before make up, begin 4.0 Profile in turn @conditional achieve.

Java8 began to offer @ Repeatable, Framework4.0 clever compatible with JSR-310. The characteristics of the @ PropertySource, @ ComponentScan promoted annotations @ PropertySources reusable, @ ComponentScans.

4.2 start

  • Added event listener comment @EventListener, as a second choice ApplicationListener programming interface.
  • @AliasFor lifted notes derived time limit conflict
  • In terms of browser cross-domain access to resources, the introduction of @CrossOrigin, as CorsRegistry Replace Annotations program.

SpringFramework 5.x annotation-driven current era

Spring Boot 2.0 SpringFramework5.0 as a bottom, the annotation driving performance is not so obvious. In SpringBoot scenario, the extensive use @ComponentScan scanning, resulting in resolution time Spring annotation mode takes longer face this problem, the introduction of 5.0 @Indexed, add an index for the Spring annotation mode.

Guess you like

Origin www.cnblogs.com/yanyouqiang/p/10981365.html