Spring common general configuration injection jar +

Common tools jar description

Providing the AOP (aspect-oriented programming) implemented: spring -aop

spring provides the integration of AspectJ framework: spring-aspects

Providing the IoC (inversion control) underlying implementation: spring-beans

IoC spring provided on the basis of functional extension of the service: spring-context

Expanded support for the spring-context: spring-context-support

spring core components: spring-core

spring expression language: spring-expression

JDBC support package provided to the spring: spring-jdbc

Integrate third-party ORM framework: spring-orm

Simple packaging unit testing and integration testing: spring-test

Package for transaction management: spring-tx

springMVC end support for web application deployment architecture: spring-web

Implement the view controller REST Web services and Web applications: spring-webmvc

 

General construction Injection:

1. Create a spring xml configuration no applictionContext.xml

2, declare an object in the spring configuration file

(Object information tells spring containers, and class id e.g., spring containers according to class, can create an object named user1 by using the constructor with no arguments reflection (default))

    id and name differences

    The actual development process, we can ignore the id and name different. It can be mixed. By getBean () can get method, this method is overloaded.

    id = "user1, user2, user3 " represents the bean has a name, and that name is user1, user2, user3 (ID not duplicate in the same configuration file) 

 

    name = "user1, user2, user3 " represents the bean have multiple names, multiple names are user1 , user2 and user3  

 

 

3, the initialization container:

ApplicationContext  ac =  new ClassPathXmlApplicationContext(applicationContext.xml);

4, call the object is injected into the spring

  GetBean obtained by the method call in the container. ac.getBean ( "object name" object type);

  Examples of acquired directly through a Bean type. ac.getBean (object type); there is a potential risk, if there are a plurality of the same object type, will be given.

Note: The need to meet the general structure injected constructor (constructor referenced objects) to succeed.

 

Guess you like

Origin www.cnblogs.com/wdss/p/10926578.html
Recommended