The first 01 chapters spring Overview

The first 01 chapters Spring Overview

 

1 Spring Overview

①Spring is an open source framework

②Spring to simplify enterprise development and health, the use of Spring, JavaBean before you can achieve a lot of features to rely on EJB implementation. The same function in the EJB to be able to achieve through complicated configuration and complex code, but in Spring is very elegant and simple.

Is a ③Spring the IOC (the DI) and AOP container frame.

Excellent characteristics of ④Spring

[1] Non-invasive : Spring-based application development in the subject may not depend on the API Spring

[2] DI : DI - Dependency Injection, inversion control (IOC) classic implementation.

[3] Oriented Programming : Aspect Oriented Programming - AOP

[4] the container : Spring is a container, and because it contains an object lifecycle management application

        [5] components of : Spring implements a simple application uses a complex arrangement of components are combined into. You can use XML and Java annotations combination of these objects in the Spring.

        [6] One-stop : Based on the IOC and AOP can integrate open source frameworks and excellent third-party libraries of various enterprise applications (in fact SpringMVC Spring itself provides the presentation layer and the Spring JDBC persistence layer).

⑤Spring current version

 

 

 

 

 

⑥Spring module

 

 

 

 

 

 

2 Spring plug installation

① plug-in package: springsource-tool-suite-3.4.0.RELEASE-e4.3.1-updatesite.zip

Procedure ②: Refer to "References: the Spring plug installation diagram .pptx"

 

3 Spring runtime environment to build

① join JAR package

         [1] Spring JAR package itself: libs the spring-framework-4.0.0.RELEASE \ directory

  

            spring-beans-4.0.0.RELEASE.jar

            spring-context-4.0.0.RELEASE.jar

            spring-core-4.0.0.RELEASE.jar

            spring-expression-4.0.0.RELEASE.jar

        [2]commons-logging-1.1.1.jar

 ② create a Spring configuration files as needed

 

4         HelloWorld

① goal: to create an object using Spring for property assignment

② Creating Student class

 

 

 

 

③ create a Spring configuration file

    <-! Objects using bean element defines a container created by the IOC ->

    <-! Class attribute specifies the bean used to create the full class name ->

    <-! Id attribute specifies a reference identification for example bean ->

    <bean id="student" class="com.atguigu.helloworld.bean.Student">

       <! - use property sub-elements for the bean property assignment ->

       <property name="studentId" value="1001"/>

       <property name="stuName" value="Tom2015"/>

       <property name="age" value="20"/>

    </bean>

 

④ test: Creating Student class instance by Spring's IOC container

1 // Create IOC container object

ApplicationContext iocContainer =

       new ClassPathXmlApplicationContext("helloworld.xml");

 

2 // Get an instance object based on the id value bean

Student student = (Student) iocContainer.getBean("student");

 

// 3. Print bean

System.out.println(student);

 

⑤ verification: Spring IOC container when you create an object, it has completed the assignment of creating and bean properties.

 

Guess you like

Origin www.cnblogs.com/yanl55555/p/11730235.html