Spring tutorial (I) Overview, spring tutorial Overview

Source: Internet
Author: User

Spring tutorial (I) Overview, spring tutorial Overview

Spring tutorial

Spring framework is an open-source Java platform that provides comprehensive infrastructure for easy and fast development of durable Java applications.

The Spring framework was originally written by Rod Johnson and was first released with the Apache June 2003 license in 2.0.

This tutorial is based on Spring framework 4.1.6 released in March 2015.


Target Audience

This tutorial is designed for Java programmers who need to learn more about the architecture of the Spring framework and the actual application. This tutorial will bring you an intermediate level of professional knowledge, and you can upgrade yourself to a higher level of professional knowledge.

Learning prerequisites

Before this tutorial, you should have a good understanding of the Java programming language. A basic understanding of Eclipse IDE is also required, because all examples are compiled using Eclipse IDE.

Overview

Spring is the most popular enterprise-level Java application development framework. Millions of developers from around the world use the Spring framework to create performance, test, and reusable code.

Spring framework is an open-source Java platform written by Rod Johnson, and was first released with the Apache June 2003 license in 2.0.

Spring is lightweight when it comes to size and transparency. The basic version of the Spring framework is about 2 MB.

The core features of the Spring framework can be used to develop any Java application, but it is necessary to expand the construction of web applications on the Java EE platform. The goal of the Spring framework is to make J2EE development easier to use. It promotes good programming practices by enabling the POJO-based programming model.

Benefits of using the Spring framework

The following lists the main benefits of using the Spring framework:

-Spring allows developers to use POJOs to develop enterprise-level applications. The advantage of using POJOs only is that you do not need an EJB container product, such as an application server, but you can choose to use a robust servlet container, such as Tomcat or some commercial products.

-Spring is organized in a unit mode. Even if the number of packages and classes is very large, you must and only need but you need to ignore the remaining part.

-Spring won't let you repeat your work in vain. It actually utilizes some existing technologies, such as several ORM frameworks, log frameworks, JEE, Quartz, and JDK timers, and other view technologies.

-It is easy to test an application written in Spring because the environment-dependent code is put into this framework. In addition, by using JavaBean-style POJOs, it becomes easier to inject test data using dependency injection.

-Spring web framework is a well-designed web MVC framework, which is a web framework, such as Structs or other engineering or rarely popular web frameworks, provides a good alternative.

-Spring provides a convenient API to translate exceptions from specific technologies (for example, exceptions thrown by JDBC, Hibernate, or JDO) into the same one, these are untested exceptions.

-Lightweight IOC containers are usually lightweight, especially when compared with EJB containers. This facilitates the development and deployment of applications on computers with limited memory and CPU resources.

-Spring provides a consistent transaction management interface, which can be reduced to a local transaction (for example, using a single database) and extended to a global transaction (for example, use JTA ).

Dependency injection (DI)

Spring most recognizes the ** dependency injection (DI) ** pattern of Reverse control. IoC is a general concept that can be expressed in many different ways. Dependency injection is just a specific example of control reversal.

When writing a complex Java application, the application class should be as independent as other Java classes as much as possible to increase the possibility of reusing these classes. During unit testing, they can be tested independently of other classes. Dependency injection (or sometimes called wiring) helps to bond these classes and keep them independent at the same time.

What is dependency injection? Let's take a look at these two words separately. Here, the dependency part is converted to the association between two classes. For example, Class A depends on Class B. Now let's take a look at the second part, injection. All of this means that Class B will be injected into Class A through IoC.

Dependency injection can occur by passing parameters to the constructor, or by using the setter method post-construction. Since dependency injection is the core part of the Spring framework, I will use a good example to explain this concept in a separate chapter.

Aspect-oriented programming (AOP ):

A key component of the Spring framework is the ** Aspect-oriented programming (AOP) ** framework. The function of crossing multiple points in a program is called ** cross-cutting concerns **. These cross-cutting concerns are conceptually independent of the application's business logic. There are a variety of common examples about the aspect, such as logging, declarative transactions, security, and caching.

In OOP, the key unit of modularization is class, while in AOP, the key unit of modularization is aspect. AOP helps you separate cross-cutting concerns from the objects they affect. However, dependency injection helps you separate your application objects from each other.

The Spring framework's AOP module provides an object-oriented programming implementation that allows you to define interceptor methods and entry points to implement the clean separation of code that should be separated. I will discuss it in an independent chapter

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.