In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to simply analyze Spring. The editor thinks it is very practical, so I hope you can get something after reading this article. Let's take a look at it with the editor.
Spring is an open source framework created by Rod Johnson. It is seen as a solution to the complexity of enterprise application development. Spring uses basic JavaBean to do things that previously could only be done by EJB. However, the use of Spring is not limited to server-side development. Any Java application can benefit from Spring in terms of simplicity, testability, and loose coupling.
To put it simply, Spring is a lightweight inversion of control (IoC) and AOP-oriented container framework. Lightweight-Spring is lightweight in terms of size and cost. Objects in Spring applications do not depend on specific classes of Spring. Control inversion-Spring promotes loose coupling through IoC technology. When it is applied, other objects that an object depends on are passed in passively, rather than the object itself creating or looking for dependent objects. It can be understood that IoC is the opposite of JNDI. Aspect-oriented-Spring provides rich support for aspect-oriented programming, allowing cohesive development by separating the application's business logic from system-level services. Application objects only do what they are supposed to do-complete the business logic-that's all. They are not responsible for other system-level concerns, such as logging or transaction support.
Container-Spring contains and manages the configuration and lifecycle of application objects, and in this sense it is a container. However, Spring should not be confused with traditional heavyweight EJB containers, which are often large and bulky and difficult to use.
Framework-Spring can combine simple components and configurations into complex applications. In Spring, application objects are grouped declaratively, typically in a XML file. Spring also provides a lot of basic functions (transaction management, persistence framework integration, etc.), leaving you with the development of application logic. [but in a sense, this increases the complexity of development, which is equivalent to a handwritten configuration file]
Introduce the history of Spring
The infrastructure of Spring, which originated in early 2000, is the infrastructure built by Rod Johnson in a number of successful business projects. In late 2002, Rod Johnson released the book "Expert One-on-One J2EE Design and Development" and provided a preliminary implementation of the development framework-the interface21 development kit. Interface21 is the concrete implementation of the ideas described in the book. Later, Rod Johnson has further modified and expanded on the basis of the interface21 development package to make it a more open, clear and comprehensive Spring framework. In February 2003, the Spring framework officially became an open source project and was released in SourceForge.
Introduce the mission of Spring
J2EE should make it easier to use object-oriented design than any implementation technology is more important to interface-oriented programming rather than class-specific programming. Spring reduces the complexity of using the interface to zero. The code should be easy to test. [this mission actually corresponds to the test-driven development approach in Agile. JavaBean provides * methods for application configuration in Java, where Checked exception is overused. The framework should not force you to catch irrecoverable exceptions.
The criticism of Spring
Spring is not a "standard". Is not part of the J2EE specification and is not approved by JCP (Java Community Process).
Spring is "super heavyweight". Because Spring involves a lot of content (for example: jdbc,ORM, remote access, etc.), but its essence is still huge of Java technology. Spring is just to provide better solutions for the use of these technologies. At the same time, you can choose the parts you need to use.
Introduce the modules included in Spring
Seven parts:
Spring AOP
Spring ORM
Spring Web
Spring Web MVC
Spring DAO
Spring Context
Spring Core
As a whole, these modules provide you with everything you need to develop enterprise applications. But you don't have to base the application entirely on the Spring framework. You are free to pick the module that suits your application and ignore other modules. All Spring modules are built on top of the core container.
Core container
This is the most basic part of the Spring framework, which provides dependency injection (Dependency Injection) features to enable the container to manage Bean. The most basic concept here is BeanFactory, which uses IoC to separate application configuration and dependency specification from the actual application code.
Application context (Context) module:
The BeanFactory of the core module makes the Spring a container, while the context module makes it a framework. This module extends the concept of BeanFactory by adding support for internationalized (I18N) messages, event propagation, and validation.
In addition, this module provides many enterprise services. Examples include email JNDI access, EJB integration, remote, and timing scheduling (scheduling) services. Support for template frameworks such as Velocity and FreeMarker integration is also included.
AOP module of Spring:
Spring provides rich support for aspect-oriented programming in its AOP module. This module is the basis of faceted programming in Spring applications. To ensure interoperability between Spring and other AOP frameworks, Spring's AOP supports API based on the AOP federation definition. The AOP Alliance is an open source project that aims to promote the use of AOP and interoperability between different AOP implementations by defining a common set of interfaces and components.
Spring's AOP module also introduces metadata programming to Spring. Using Spring's metadata support, you can add comments to your source code to instruct Spring where to apply aspect functions.
JDBC abstraction and DAO modules:
Using JDBC often leads to a lot of duplicate code, getting connections, creating statements, processing result sets, and then closing Spring's JDBC and DAO modules to extract these duplicate code, so you can maintain your database access connection. The code is clean and concise, and can prevent problems caused by failure to close database resources. This module also establishes a meaningful anomaly layer based on the error messages given by several database servers. So that you no longer have to try to decipher the mysterious private SQL error message! In addition, this module also uses Spring's AOP module to provide transaction management services for objects in Spring applications.
ORM (object / Relational Mapping Integration Module):
For those who prefer to use object / relational mapping tools rather than using JDBC directly, Spring provides the ORM module. Instead of trying to implement its own ORM solution, Spring provides an integration solution for several popular ORM frameworks, including Hibernate, JDO, and iBATIS SQL mapping. Spring's transaction management supports each of these ORM frameworks, including JDBC.
Web module of Spring:
The Web context module is based on the application context module and provides a context suitable for Web applications. For example: to achieve file upload multipart request, in addition, this module also provides some service-oriented support. Provides integration of Spring and other Web frameworks, such as Struts, WebWork.
Spring's MVC framework:
Spring provides a full-featured MVC framework for building Web applications. Although Spring can be easily integrated with other MVC frameworks, such as Struts, Spring's MVC framework uses IoC to provide complete separation of control logic and business objects.
Spring brings the spring of complex J2EE development. Its core is lightweight IoC container, its goal is to provide an omni-directional integration framework for J2EE applications, to achieve the combination of multiple sub-frameworks under the Spring framework, these sub-frameworks can be independent of each other, but also can be replaced by other framework schemes. Spring hopes to provide one-stop (one-stop shop) solutions for enterprise applications.
The above is how to simply analyze Spring. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.