Spring Framework Introduction


Introduction Spring Framework
Spring Framework module
Spring development environment to build (the Eclipse)
to create a simple Spring application
Spring Inversion of Control container (Inversion of Control - IOC)
understood dependency injection (the DI - the Dependency Injection)
Bean XML configuration (1) - through XML configuration load Bean
Bean the XML configuration (2) - Bean scope and lifecycle callbacks arranged
Bean the XML configuration (3) - configuration dependency injection
Bean the XML configuration (4) - automatic assembly
Bean annotations (annotation) configuration (1) - loading by annotations Bean
Bean annotation (annotation) configuration (2) - Bean scope and lifecycle callbacks configuration
Bean annotation (annotation) configuration (3) - Dependency injection configuration
Bean Java configuration
Spring Aspect oriented programming (AOP)
Spring event (1) - built-in event
Spring event (2) - custom event


Spring is a JEE development framework, open source, lightweight and powerful.

Java Enterprise Edition / Java Enterprise Edition - JEE
the Java version is mainly used for the development of enterprise software. Examples of enterprise software: accounting software, billing management, business process management, CMS, CRM, ERP and so on.

The core characteristics of the Spring Framework dependency injection (DI) and Aspect Oriented Programming (AOP), Spring frame inversion can be seen as a control vessel. Although Spring is mainly used for JEE application development, but in fact these two core features can be used for any Java project.

Spring Framework is the most popular Java EE development framework, it has become the de facto standard JEE developers around the world are using the Spring framework to develop a variety of applications.

Spring Framework is an Australian computer expert Roderick B. Johnson was released in 2002, since the birth of the released many versions, the latest version is 5.0

version time Remark
0.9 2002
1.0 2003 Released
2.0 2006
3.0 2009
4.0 2013
5.0 2017

Spring Framework advantage

  • Loose coupling , dependencies between components (Bean) is very loose, modules can easily be replaced
  • Simple, non-invasive , itself just a simple Java object components (Bean), without any special treatment, very simple

Dependency injection / DI (Inversion of Control / IOC)

One of the two core technologies Spring Framework dependency injection (Dependency Injection / DI).

Java program, Java class is the basic unit of code organization. When a class to use another class, the natural approach is to create objects of another class, then call the method of the object. To do so in the smaller size of the program no problem, but too tight coupling between these classes is large-scale program will lead to subsequent development and maintenance difficulties. For example, to replace one of these categories, we have to change all the code involved in this class.

Inversion of control (Inversion of Control / IoC) and dependency injection (Dependency Injection / DI) is to solve this problem. The above-mentioned categories which create another class object will result in tight coupling, put the Spring Framework to create a behavior class out into the Spring framework to do it from the class, create a relationship between classes is not.

Create a class object on which it depends have been controlled by the class, now put into action to create the Spring framework, all class objects created by frame control, which is the "inversion of control."

Framework creates a class dependent objects, then these objects are passed (injected) depend on their class, which is the "dependency injection."

So you can see, Spring Framework inversion of control (Inversion of Control / IoC) and dependency injection (Dependency Injection / DI) is actually talking about the same thing, but a different angle.

About dependency injection, details will follow.

Oriented Programming / AOP

Further Spring Framework is a core technology of Aspect Oriented Programming (Aspect Oriented Programming / AOP).

The main role of Aspect Oriented Programming is, without source code modification, the target class can be patched, the patch is allowed to execute the code.

For example, a user login class has a method, now we need to add the user login log. Use AOP no need to modify user login method, the log just before and after the user logs into the code injection method, allowed to execute. Logging code is "cut", places (user login method and the like) is inserted into the code, "the point of attachment."

About AOP follow-up will be described in detail.

Note: Dependency injection / DI (Inversion of Control / IOC) and Oriented Programming / AOP are based on Java reflection mechanism.

Guess you like

Origin www.cnblogs.com/jinbuqi/p/10953492.html