Bowl --- build an overview of Spring and the environment

Spring What is

  Spring is made of a lightweight Java framework Apache developers can be more convenient to use JavaBean (EJB previously only be achieved)

  The main advantage of Spring: layered architecture:

    1. DAO layer interfaces (Data Access object) data access object, a database:
    2. Service layer: For traffic judgment process and 
    3. Layer Controller: receiving requests, and user interaction page of

  Spring is an IOC (DI) and AOP container frame.

    It should explain what is the IOC, what is AOP

    1. the IOC (the DI): Inversion Inversion of Control Control of

  It is a design pattern: When an object is created by an outside entity for all objects within a regulatory system will reference its dependent objects passed to it. (Popular terms: A class of objects called Class B b, can directly call the object is injected into the well outside new class A, to avoid the coupling between internal) and it is the most common method of dependency injection (Dependency Injection abbreviation: DI)

2. AOP:  Aspect Oriented Programming Aspect Oriented Programming

  Precompiled management and dynamic way during operation, implemented on the basis of the modified source code without addition of a technical function to the program, such as logging, performance statistics from the business logic code dividing code. When to change their behavior does not affect other business logic code.

Spring  development environment to build

  Jar package 1 desired:

    (1) spring-context: loading the bean definition and assembled.

  (2) spring-core: find, establish and maintain a list of tools needed for the relationship between the bean and bean

  (3) spring-beans: (protagonist in Spring) Spring dependency injection is out of the new package is injected into the object program in the bean

  (4) spring-expression: a powerful expression parsing language that supports dynamic analytical expression to an object at runtime assignment (currently not quite understand)

  (5) commons-logging: provides a simple log and the log function decoupling (decoupling function for the time being not used)

By loading maven project:

 1   <dependencies>
 2           <dependency>
 3             <groupId>org.springframework</groupId>
 4             <artifactId>spring-context</artifactId>
 5             <version>5.2.0.RELEASE</version>
 6         </dependency>
 7         <dependency>
 8             <groupId>org.springframework</groupId>
 9             <artifactId>spring-core</artifactId>
10             <version>5.2.0.RELEASE</version>
11         </dependency>
12         <dependency>
13             <groupId>org.springframework</groupId>
14             <artifactId>spring-beans</artifactId>
15             <version>5.2.0.RELEASE</version>
16         </dependency>
17         <dependency>
18             <groupId>org.springframework</groupId>
19             <artifactId>spring-expression</artifactId>
20             <version>5.2.0.RELEASE</version>
21         </dependency>
22         <dependency>
23             <groupId>commons-logging</groupId>
24             <artifactId>commons-logging</artifactId>
25             <version>1.2</version>
26         </dependency>
27   </dependencies>

 

2. xml configuration file

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context.xsd ">

</beans>

  Spring configurations for Spring Bean production factory, and Bean instance dependency injection. Which is named Spring applicationContext.xml default configuration file, when the container is not specified other xml documents, the file loaded by default.

  Beans and tag information parsing attribute xml file:

  (1) beans: whole root profile, comprising one or more elements bean

  (2) xmlns: xml namespace specified current xml namespace

  (3) xmlns: xsi: it refers to a label to be followed xml specification, a property of xmlns

  (4) xsi: schemaLocation: specified namespace corresponding verification file is xml to follow when writing syntax for declaring a target namespace of the schema document. a property of xsi. In schemaLocation references are pairs exist.

  E.g:

http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 

 

  (5) xsd file: define the structure of XML Schemas Definition xml

  

Guess you like

Origin www.cnblogs.com/zzu-superYi/p/11824861.html