spring--Baidu Encyclopedia

Source: Internet
Author: User
Tags dotnet to domain

Spring is an open source framework, and spring is a lightweight Java development framework that emerged in 2003 by Rod Johnson in his book expert one-on-one development and Some of the concepts and prototypes elaborated in design are derived. It is created to address the complexities of enterprise application development. One of the main advantages of the framework is its layered architecture, which allows the user to choose which component to use, while providing an integrated framework for Java EE application development. Spring uses basic JavaBean to accomplish things that were previously only possible by EJBS. However, the use of spring is not limited to server-side development. From the standpoint of simplicity, testability, and loose coupling, any Java application can benefit from spring. The core of spring is control inversion (IoC) and facet-oriented (AOP). In simple terms, spring is a layered javase/ee Full-stack ( one-stop)Lightweight open source framework.
Chinese name
Spring Open Source Framework
Foreign names
Solving the complexities of enterprise application development
Use basic JavaBean instead of EJB
any Java application
    1. 1 Origins
    2. 2 Background
    3. 3 Frame Characteristics
    4. 4 features
    5. 5 features
    1. 6 Benefits
    2. 7 Effects
    3. 8 Basic Framework
    4. 9 Download and install
    5. Application Examples
    1. Main Products
    2. Step
    3. Container
Origin Editor You may be thinking, "Spring is just another framework." Why do we need the spring Framework when there are already many open source (and proprietary) J2eeframework? Spring is unique for a number of reasons: it locates areas that are not in many other popular frameworks. Spring is dedicated to providing a way to manage your business objects. Spring is comprehensive and modular. Spring has a layered architecture, which means that you can choose to use any part of it that is isolated, and that its architecture remains inherently stable. So from your study, you can get the greatest value. For example, you might choose to use spring only to simplify the use of JDBC, or to manage all business objects. It's designed from the bottom to help you write code that is easy to test. Spring is the ideal framework for testing drive engineering. Spring does not require more than one framework for your project. Spring is a potentially one-stop solution for most of the infrastructure associated with typical applications. It also relates to content that is not considered by other frameworks. Background editor Rod Johnson, in his book "Expert One on one, development," in 2002, questioned the state of the Java EE System framework, which was bloated, inefficient, detached from reality, and actively sought to explore the path of innovation. With this book as the guiding ideology, he wrote the INTERFACE21 framework, an attempt to break through the traditional development of Java EE, from the actual needs of the light, agile, easy to develop, test and deploy a lightweight development framework. The spring framework, which is based on the INTERFACE21 framework, has been redesigned and enriched, and has been released on March 24, 2004, with 1.0 official editions. In the same year he launched a classic masterpiece, "Expert One-on-one development without EJB", which has stirred up a firestorm in the Java world, constantly changing the way Java developers think about programming and development. In this book, the author based on his years of rich practical experience, the EJB's various cumbersome and bloated structure of a one-to-one analysis and negation, and respectively, in a concise and practical way to replace. At this point, Rod Johnson became a master figure who changed the Java world. Traditional Java EE application development efficiency is low, the application server vendor's support to various technologies is not really unified, resulting in the application of Java EE does not really realize the commitment of write once and run anywhere. Spring asOpen source middleware, independent of various application servers, even without application server support, can also provide application server functions, such as declarative transactions, transaction processing and so on. Spring is dedicated to the solutions of each layer of the Java EE application, rather than just focusing on one layer of the solution. It can be said that spring is the "one-stop" choice of enterprise application development, and runs through the performance layer, the business layer and the persistence layer. However, spring does not want to replace those existing frameworks, but rather seamlessly integrate them with them. Frame feature Editing Light weightSpring is lightweight, both in terms of size and overhead. The full spring framework can be published in a jar file with a size of more than 1MB. and the processing overhead required by spring is negligible. In addition, spring is non-intrusive: Typically, objects in spring applications do not depend on a particular class of spring. Control reversal--spring facilitates low coupling through a technique called inversion of Control (IoC). When an IOC is applied, other objects that an object relies on are passed in passively, rather than the object itself creating or locating dependent objects. You can think of the IOC as opposed to Jndi--not the object looking for dependencies from the container, but the container actively passing the dependency to it when the object is initialized without waiting for the object to be requested. Face Tangent--spring provides rich support for aspect-oriented programming, allowing for the development of cohesion through the separation of application business logic with system-level services such as auditing (auditing) and transaction (transaction) management. The Application object only implements what they should do-complete the business logic-that's all. They are not responsible (or even conscious) for other system-level concerns, such as log or transaction support. Container--spring contains and manages the configuration and lifecycle of the Application object, in this sense it is a container where you can configure how each of your beans is created-based on a configurable prototype (prototype), Your bean can create a separate instance or generate a new instance each time it is needed-and how they relate to each other. However, spring should not be confused with traditional heavyweight ejb containers, which are often bulky and cumbersome and difficult to use. Framework--spring can be used to configure and assemble simple components into complex applications. In spring, application objects are combined declaratively, typically in an XML file. Spring also provides a number of basic functions (transaction management, persistence framework integration, etc.), leaving the development of application logic to you. The role of mvc--spring is to integrate, but not just to integrate, the Spring framework can be seen as an enterprise solution-level framework. The client sends the request, the server controller (implemented by Dispatcherservlet) completes the forwarding of the request, and the controller invokes a class handlermapping for the mapping, which is used to map the request to the corresponding processor to process the request. Handlermapping maps the request to the corresponding processor controller (equivalent to action) in spring if you write some processor components, generally implement the Controller interface, in the controller can call some service or DAO for data manipulation Modelandview is used to hold data taken from the DAO, and it can hold some data from the response view. If you want to return the processing results to the user, a view component, Viewresolver, is provided in the spring framework, which finds the corresponding view based on the indicator returned by the controller, and returns the response response to the user. All of these features of spring enable you to write cleaner, more manageable, and easier-to-test code. They also provide basic support for the various modules in spring. Features edit the powerful JavaBeans-based configuration management with the inversion of control,ioc principle, making application components faster and easier. A core Bean factory that can be used in different operating environments, from applets to Java EE. The generalized abstraction layer of a database transaction, allowing the declarative (declarative) transaction manager to simplify the partitioning of the transaction so that it is not related to the underlying. Built-in generalized policy for JTA and a single JDBC data source, so that Spring's transaction support does not require Java EE ringContrary to the general JTA or EJB CMT. The JDBC abstraction layer provides a targeted exception level (no longer extracting the original code from the SQL exception), simplifying error handling and greatly reducing the amount of coding the programmer has. When using JDBC again, you don't have to write another ' terminate ' (finally) module. and a JDBC-oriented exception is consistent with the spring universal data Access object exception level. Integrates with Hibernate,jdo and IBATIS SQL Maps in the form of resource containers, DAO implementations, and transaction policies. Many typical hibernate integration problems are solved by using many of the inversion control convenience features to fully support. All of these comply with the spring general transaction and generic data Access object exception level specification. Flexible framework for MVC Web applications based on core spring functionality. The developer will have a high degree of control over the framework through the policy interface, so the framework will adapt to a variety of rendering (View) technologies such as Jsp,freemarker,velocity,tiles,itext and POI. It is worth noting that the Spring middle tier can easily be combined with any MVC framework-based web layer, such as struts,webwork, or Tapestry. Provides a facet-oriented programming (AOP) framework for services such as transaction management. [1]  Feature Editor 1. Easy to decouple and simplify developmentWith the IOC container provided by spring, we can control the dependencies between objects by spring, avoiding excessive program coupling caused by hard coding. With spring, users no longer have to write code for these very low-level requirements, such as single-instance pattern classes, attribute file parsing, and can focus more on upper-tier applications. 2.AOP Programming the supportThe AOP functionality provided by spring facilitates aspect-oriented programming, and many features that are not easily implemented with traditional OOP can be easily coped with by AOP. 3. Declarative Transactions the supportIn spring, we can get rid of the tedious transaction management code, make the transaction management with the declarative way, improve the development efficiency and quality. 4. Convenient program TestingAlmost all of the testing can be done with non-container-dependent programming, and in spring, testing is no longer an expensive operation, but something that can be done at hand. For example, Spring supports JUNIT4, which can be easily tested with annotations for spring programs. 5. Easy integration of various excellent frameworksSpring does not exclude a variety of excellent open source frameworks, instead, spring can reduce the difficulty of using various frameworks, and spring provides direct support for a variety of excellent frameworks such as Struts,hibernate, Hessian, Quartz, etc. 6. Reduce the difficulty of using Java EE APIsSpring provides a thin layer of packaging for many of the hard-to-use Java EE APIs, such as Jdbc,javamail, remote invocation, and so on, and the ease of use of these Java EE APIs is greatly reduced by spring's simple encapsulation. 7.Java Source code is a classic learning paradigmSpring's source code design is exquisite, the structure is clear, the ingenuity uses, everywhere manifests the master to the Java design pattern flexible use as well as to the Java Technology Advanced attainments. The spring framework source code is undoubtedly a best practice example of Java technology. If you want to quickly improve your Java technology and application development level in a short period of time, learning and studying spring source code will make you receive unexpected results. Benefit editors before we go into the details, let's take a look at some of the benefits that spring can bring to a project: spring can effectively organize your middle-tier objects, whether or not you choose to use EJBS. If you just use struts or other frameworks that contain the Java EE-specific APIs, you'll find that spring is focused on the legacy. Spring can eliminate the excessive use of singleton in many projects. Based on my experience, this is a major problem, which reduces the testability and object-oriented nature of the system. Spring eliminates the need to customize files with attributes in a variety of formats, and is configured in a consistent way throughout the application and engineering. Ever confused, a particular class looking for a psychedelic attribute keyword or system attribute, do you have to read Javadoc or even source code? With Spring, you can easily see the JavaBean property of the class. The use of inverted controls (discussed below) helps to accomplish this simplification. Spring can promote good programming habits through interfaces rather than classes, reducing programming costs to almost zero. Spring is designed so that applications created with it depend as little as possible on his APIs. Most business objects in a spring application are not dependent on spring. Applications built using spring are easy to unit test. Spring enables the use of EJBS to be 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 are suitable for many Web applications. For example, spring can use AOP to provide declarative transactions without using an EJB container, if you only need to deal with a single database, and you don't even need a JTA implementation. Spring provides a consistent framework for data access, whether using JDBC or O/R mapping products such as hibernate. Spring does enable you to solve your problem with the simplest possible solution. These features are of great value. To summarize, spring has the following advantages: 1. Low-intrusive design, code pollution is very low 2. Application-independent application servers, based on spring framework applications, can really implement write Once,rUN anywhere's commitment 3.Spring di mechanism reduces complexity of business object substitution and improves decoupling between components 4.Spring AOP support allows for centralized management of some common tasks such as security, transactions, logs, and so on, providing better reuse 5. Spring's ORM and DAO provide good integration with the third-party persistence layer framework and simplify the underlying database access 6. Spring does not force applications to rely entirely on spring, and developers are free to choose part or all of the role of the spring Framework to edit spring provides many features, where I will quickly show each of its main aspects in turn. First, let's clarify the spring range. Although spring covers many aspects, we already have a clear concept of what it should involve and what should not be involved. The main purpose of spring is to make Java EE easy to use and promote good programming habits. Spring does not re-develop what is already there. Therefore, in spring you will find a packet without logging, no connection pool, and no distributed transaction scheduling. These are available in open source projects (for example Commons Logging is used to do all the log output, or commons dbcp used as a data connection pool) or provided by your application server. For the same reason, we did not provide the O/R mapping layer, and there are friendly solutions such as Hibernate and JDO. Spring's goal is to make existing technologies easier to use。 For example, although we do not reconcile the underlying transaction, we provide an abstraction layer that overrides JTA or any other transaction policy. Spring does not compete directly with other open source projects unless we feel that we can offer something new. For example, like many developers, we have never been happy with struts and feel that there is room for improvement in the MVC Web framework. In some areas, such as the lightweight IOC container and the AOP framework, Spring has direct competition, but there are no already popular solutions in these areas. (Spring is a pioneer in these areas.) ) Spring also benefits from intrinsic consistency. All the developers are singing the same hymn, the basic idea is still the expert one-on-one EE design and development of those. And we have been able to use some of the main concepts, such as inverted control, to handle multiple areas. Spring inThe application servers are portable. Of course, portability is always a challenge, but we avoid any particular platform or non-standardization, and support users on Weblogic,tomcat,resin,jboss,websphere and other application servers. The basic Framework Editor Spring Framework is a layered architecture consisting of 7 well-defined modules. The spring module is built on top of the core container, and the core container defines how the beans are created, configured, and managed: Each module (or component) that makes up the spring framework can exist separately or be implemented in conjunction with one or more modules. The functions of each module are as follows: 1. Core container: The core container provides the basic functionality of the spring Framework (Spring Core). The main component of the core container is Beanfactory, which is the implementation of the factory pattern. The beanfactory uses the inversion of control (IOC) pattern to separate the application's configuration and dependency specifications from the actual application code. 2. Spring Context: The spring context is a configuration file that provides contextual information to the spring framework. The Spring context includes enterprise services such as Jndi, EJB, e-mail, internationalization, checksum scheduling. 3. Spring AOP: With the configuration management feature, the Spring AOP module directly integrates the aspect-oriented programming functionality into the Spring framework. Therefore, it is easy to enable any object managed by the Spring framework to support AOP. The spring AOP module provides transaction management services for objects in spring-based applications. By using Spring AOP, you can integrate declarative transaction management into your application without relying on EJB components. 4. The Spring Dao:jdbcdao Abstraction layer provides a meaningful exception hierarchy that can be used to manage exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the number of exception codes that need to be written (such as opening and closing connections). Spring DAO's JDBC-oriented exception conforms to the common DAO exception hierarchy. 5. The Spring orm:spring Framework inserts several ORM frameworks, providing ORM object-relational tools, including JDO, Hibernate, and Ibatissql Map. All of these conform to Spring's common transaction and DAO exception hierarchies. 6. Spring Web Module: The Web context module is built on top of the application context module and provides the context for Web-based applications. Therefore, the spring framework supports the JakartaThe integration of Struts. The Web module also simplifies the process of working with multipart requests and binding request parameters to domain objects. 7. Spring MVC Framework: The MVC Framework is a full-featured MVC implementation of building Web applications. With the policy interface, the MVC framework becomes highly configurable, and MVC accommodates a large number of view technologies, including JSP, Velocity, Tiles, IText, and POI. The model is composed of JavaBean, which is stored in map, the view is an interface, is responsible for displaying the model, and the controller represents the logic code. The functionality of the spring framework can be used in any Java EE server, and most features are also available in an out-of-management environment. The core point of Spring is to support reusable business and data access objects that are not tied to a particular Java EE service. There is no doubt that such objects can be reused across different Java EE environments (Web or EJB), standalone applications, and test environments. Download and install the edit download and install spring follow the steps below. (1) Log in to the site and download the latest stable version of spring. The latest version is spring-framework-4.0. Recommended download spring-framework-spring-framework-4.0.0.m2-distThis package contains not only the spring development package, but also the third-party class libraries that spring compiles and runs on. Unzip the downloaded package and apply the following folders to the extracted folder. Dist: This folder takes Spring's jar package, usually just spring.jar files. This folder also has some Spring-xxx.jar-like compression packages, which are sub-module compressed packages of the Spring.jar compressed package. Consider using this sub-module compression package unless you are sure that the entire Java EE application only needs to use one aspect of spring. It is generally recommended to use Spring.jar Docs: This folder contains spring-related documentation, development guides, and API reference documentation. Lib: This folder contains the third-party class libraries that spring compiles and runs on, and the class libraries under that path are not required by spring, but if you need support from a third-party class library, the class library is required. Samples: This folder contains a few simple examples of spring, which can be used as a case for spring's introductory learning. src: This folder contains all the source files of spring, if there is no place in the development process, you can refer to the source file to understand the underlying implementation. Test: This folder contains spring's test examples. Tiger: The path under which the contents of the JDK are stored under the extracted folder, Also includes some license and project-related files on spring (2) Copy the Spring.jar to the classpath path of the project, and for the web app, copy the Spring.jar file to the Web-inf/lib path, The application can take advantage of the spring framework. (3) Typically spring's framework also relies on some other jar files, so it is also necessary to copy the corresponding packages under Lib to the Web-inf/lib path, specifically which jar files to copy, depending on the project that the application needs to use. It is often necessary to copy the jar files under folders such as cglib,dom4j,jakarta-commons,log4j. (4) In order to compile the Java file, you can find the base class of spring and add the path of the Spring.jar file to the environment variable CLASSPATH. Of course, you can also use the Ant tool, but you don't need to add environment variables. If you use an IDE such as Eclipse or NetBeans, you do not need to set environment variables. Spring MVCThe view presentation layer of the traditional Web architecture uses struts as the presentation layer. But if you try out the MVC that comes with spring, you'll find that spring can replace struts in a general situation. In some ways, spring's MVC design is more reasonable and interesting, so try a single spring MVC. Application instance Editing
    1. Create a new landing page: loginactionsupport.jsp, the code is as follows
<% @page contenttype= "TEXT/HTML;CHARSET=GBK" iselignored= "false"%> Spring. NETSpring is not specific to Java, it is also applied to. NET platform. and has been very good development! Spring DOTNET is a concern. NET Enterprise Application Development Application framework. It provides a wide range of functions, such as dependency injection, aspect-oriented programming (AOP), data access abstraction, and ASP dotnet integration. The core concepts and values of the Java-based spring framework have been applied to. NET. Spring DOTNET 1.0 contains a fully functional dependency injection container and an AOP library. Subsequent releases will include support for ASP DOTNET, remoting, and data access. Step editing spring does allow you to solve your problem with the simplest possible solution. And that's a lot of value. At the same time, his source code design philosophy has been sought after by many programmers, concise, easy-to-use. But from where to study spring is a lot of novice headache, the following reference will lead you to slowly analyze the springSpring1 transaction processing in Spring 2 IOC container start in Web container 3 spring JDBC4 Spring MVC5 spring AOP get Proxy6 Spring Declarative Transaction 7 implementation of interceptor invocation in spring AOP 8 Spring Driver Hibernate implementation of 9 Spring Acegi Framework Authentication IOC and AOPThe basic concept of control reversal mode (also known as dependency injection) is that you do not create objects, but describe how they are created. The code does not directly connect to objects and services, but describes in the configuration file which component requires which service. Containers (which are IOC containers in the Spring framework) are responsible for linking these together. In a typical IOC scenario, the container creates all the objects and sets the necessary properties to connect them together, deciding when to invoke the method. The following table lists an implementation pattern for the IOC.
Type 1 the service needs to implement a dedicated interface, Through interfaces, these services are provided by objects that can query dependencies (for example, required additional services) "interface injection" from an object.
Type 2 assigns dependency "setter method injection" through the properties of the JavaBean, such as setter methods. The
Type 3 dependency is provided as a constructor and does not expose "constructor injection" in the form of a JavaBean property.
The IOC container for the Spring framework is implemented with type 2 and type 3. 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 and IOC are complementary technologies that use a modular approach to solve complex problems in enterprise application development. In a typical object-oriented development approach, logging statements may be placed in all methods and Java classes in order to implement logging functionality. In the AOP approach, the log service can be modularized in turn and applied declaratively to the component that needs the log. Of course, the advantage is that the Java class does not need to know the existence of the log service and does not need to consider the associated code. Therefore, application code written in Spring AOP is loosely coupled. The functionality of AOP is fully integrated into the context of spring transaction management, logging, and various other features. In AOP programming, Spring offers many features, such as PointCut, Advice, and Advisor, which are roughly the point of entry for transaction management, logging, and various other features. The core of the container editing spring design is the Org.springframework.beans package, which is designed to be used with the JavaBean component. This package is not usually used directly by the user, but is used by the server as the underlying intermediary for most other functions. The next highest-level abstraction is the Beanfactory interface, which is the implementation of the factory design pattern, allowing objects to be created and retrieved by name. Beanfactory can also manage the relationships between objects. The beanfactory supports two object models. 1. A single-state model provides a shared instance of an object with a specific name, which can be retrieved at query time. Singleton is the default and most commonly used object model. Ideal for stateless service objects. 2. The prototype model ensures that each retrieval creates a separate object. The prototype model works best when each user needs his or her own object. The Bean Factory concept is the basis of Spring as an IOC container. The IOC shifts responsibility for handling things from application code to frameworks.

spring--Baidu Encyclopedia

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.