Advantages and disadvantages of spring learning

Source: Internet
Author: User


1. Spring working mechanism and why should it be used?

Spring is an open source framework that is created to address the complexities of enterprise application development. Spring is both an AOP framework and an IOC container.

Springframework's composition: Spring aop,spring dao,spring orm,spring web,spring Context, Spring Web MVC.

The core of spring is IOC and AOP, so spring's working mechanism is simply understood as the working mechanism of IOC and AOP.

The Spring aop,spring IOC makes it easy to use very robust, flexible enterprise-class services, which can reduce coupling between components by using IOC, ultimately improving class reusability, testing, and better integration and configuration of the entire product or system.

2. What is the concept of AOP and IOC and how is it applied in spring?

Aop,aspect oriented program, programming for (aspect) facets;

Ioc,invert of control, inversion of controls.

(IOC is control reversal, is the core idea of spring.) Dynamic reliance on business components is achieved through interface-oriented programming.

AOP is aspect-oriented programming, not only in spring or Java, but also in object-oriented programming (OOP), which is a relatively different kind of programming idea.

Spring uses the Java Proxy mechanism to implement AOP programming.


To put it simply, theIOC is actually a dependency injection, that is, the interface programming, in the program does not appear the new keyword, but the interface to name the reference, and then in some way the interface of an instance of an implementation class injected into the reference, so that the interface and the implementation of the specific class loosely coupled.

  The relationship between the container control program (through XML configuration), rather than being manipulated directly by the program code in the traditional implementation, (when referencing another class object in a class object, we usually go directly through new contructor). Control is transferred from the application code to the external container, and the transfer of control is called reversal .

  The AOP approach is similar to filter, which is to insert many other code that needs to be executed in the middle of a normal business flow, such as logging in when logging in to the login page, especially when it comes to the database. or the payment-related program will definitely insert the log in front of each step. aspect-oriented programming, AOP, is a programming technique that allows programmers to modularize the behavior of crosscutting concerns or crosscutting typical lines of responsibility, such as logging and transaction management. The core structure of AOP is the facet, which encapsulates behaviors that affect multiple classes into reusable modules.

AOP Advice (AOP enhancement) is divided into:

Front-mounted enhancements

Post Enhancement

Exception enhancement

Surround enhancement

3. How many ways does spring's business matter? Talk about the isolation level and propagation behavior of spring things?

Declarative Transactions use spring declarative transactions, and spring uses AOP to support declarative transactions, automatically deciding whether to open a transaction before a method call, based on the transaction properties, and determining the transaction commits or rolls back after the method executes.

Isolation level of the transaction:

The database system provides 4 transaction isolation levels, with the highest isolation level in the 4 isolation levels and the lowest isolation level of Read uncommitted;

· READ UNCOMMITTED reading uncommitted data; (dirty reads will occur)

· Read Committed reading submitted data;

· REPEATABLE read repeatable reading;

· Serializable serialization

The propagation properties of a transaction include:

· The Required business method needs to run in a transaction, and if a method is already in a transaction, it is added to the transaction, otherwise a new transaction is created for itself, and the 80% method uses that propagation property;

· not-supported

· RequiresNew

· Mandatoky

· Supports

· Never

· Nested

4. What are the advantages and disadvantages of spring?

Advantages of ⑴spring:

①spring can effectively organize your middle-tier objects, whether or not you choose to use EJBS;

②spring can eliminate the overuse of singleton that is common in many projects. (because it reduces the testability of the system and the degree of object-oriented);

③ processing configuration files through a consistent approach across applications and projects, spring eliminates the need for properties files in a variety of custom formats. The use of inversion of control has helped to complete this simplification;

④ the cost of programming the interface rather than the class is almost reduced to no, spring can promote good programming habits;

⑤spring is designed to allow applications created with it to rely as little as possible on his APIs, and most business objects in spring applications do not rely on spring;

⑥ applications built using spring are easy to unit test;

⑦spring can make EJB usage an implementation choice, not an inevitable choice for application architectures. You can choose to use POJOs or local EJBS to implement the business interface without affecting the calling code;

⑧spring helps you solve many problems without using EJBS. Spring provides an alternative to EJBS that can be used in many Web applications. For example, spring can use AOP to provide declarative transaction management instead of through EJB containers;

⑨spring provides a consistent framework for data access regardless of whether you are using JDBC or O/R mapping products;

Disadvantages of ⑵spring:

① use a few people, JSP to write a lot of code;

The ② controller is too flexible and lacks a common controller.

Advantages and disadvantages of spring learning

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: 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.