Spring's IOC Getting Started

First, the establishment of a web project

Second, the need to import a total of two packages of content

    1, spring-framwork-4.2.4.RELEASE-dist.zip (spring his bag)

    2, spring dependent packages

    This article requires:

      libs in beans, core, context, expression

                Note: The package will also find a spring framework logging at runtime: commons-logging.jar (must be imported)

        Enterprise developers need to use the log package: apache-log4j.jar

        Two more than all import

    3, in the following src create a new profile applicationContext.xml (recommended applicationContext name)

      All documents written constraints, all constraints are put out to an html file (file location: spring-framwork-4.2.4.RELEASE-dist.zip-docs-spring-framework-reference - html - xsd- configuration.html-- copy the code 40.2.12the beans schema of <beans> </ beans> placed in the applicationContext.xml)

        Note: Constraints site at: http: //www.springframework.org/schema/beans

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

      Note: The above constraints there will be a URL is found on the Internet, we need to import local constraints. In fact we have a local constraint jar package (location: spring-framwork-4.2.4.RELEASE - schema - beans - spring- beans-4.2.xsd).

          window - preference-- Find XML Catalog-- click ADD - key constraint placed the actual address of the network address corresponding to local constraints spring http://www.springframework.org/schema/beans/spring-beans.xsd;location -framwork-4.2.4.RELEASE - schema - beans - spring- beans-4.2.xsd-- click OK -------- the import local constraints.

Code functions to achieve:

Code 1:

  1, create an interface class Car

    

  2, create a class that implements CarImpl

 

3. Create a class that implements CarTest

Code 2:

1, create an interface class Person

   

2, create a class that implements PersonImpl

3, create a test class UserTest

Two or more spring IOC authentication code, needs to be arranged in the applicationContext.xml

 

 

 

 

 

        

    

Guess you like

Origin www.cnblogs.com/zsj03180204/p/10948259.html