Spring4.0 is a major version of Spring's upgrade that further strengthens Sring's position as the first open source platform in the Java world. Spring4.0 introduces new features that many Java developers expect, such as generic dependency injection, SPEL, checksum format framework, RESTful WEB programming model, and more. These new features are practical and easy to use, greatly reducing the difficulty of Java EE development, while effectively improving the elegance of application development.
Let's start with the understanding of spring: Spring is an open source framework, and it's designed to simplify enterprise-class application development. Using Spring enables simple JavaBean to implement functionality that was previously only available to EJBS; Spring is an IOC (DI) and an AOP container framework.
Lightweight : Spring is non-invasive-objects in spring-based applications can be independent of spring's API
Dependency Injection (DI---Dependency injection, IOC)
plane-oriented programming (AOP---aspect oriented programming)
container : Spring is a container because it contains and manages the life cycle of the Application object
Framework : Spring implements a complex application that is combined with a simple component configuration. These objects can be combined in Spring using XML and Java annotations
One-stop : Integration of open source frameworks and excellent third-party libraries for enterprise applications based on IOC and AOP (in fact, spring itself provides the SPRINGMVC and persistence layer of spring JDBC for the presentation layer)
Spring's modular structure:
Simply create a spring project:
1. I am using the Spring tool suite,eclipse, an integrated spring IDE.
2. Create a MAVEN project that introduces Spring's jar package.
3. Create an App context profile-applicationcontext.xml.
4. Create a Bean object-hello.java
Packagespring.demo_01; Public classHello {PrivateString name; PublicString GetName () {returnname; } Public voidsetName (String name) { This. Name =name; } Public voidHello () {System.out.println ("Hello" +name); }}
5. Configure the Bean object in Applicationcontext.xml:
6. Load the configuration file and create an instance of the Bean object-hello.
Note: In step 1, when you create a container object, the instance object in the configuration file has been created automatically, and the corresponding property values have been injected.
In this way, one of the simplest spring projects is created.
A brief introduction to Spring4-1-spring