Thanks to the Free videos released by itcast.
SpringIsIOCAndAOPContainer
The control flip application itself is not responsible for the creation and maintenance of dependent objects. the creation and maintenance of dependent objects are the responsibility of the oil external container. The control right has the application transferred to the external container, and the control right transfer is the so-called reversal.
Dependency injection refers to the Dynamic Injection of dependent objects into components by external containers during runtime.
UseSpringBenefits:
Reduce the Coupling Degree between components and realize decoupling between different layers of software (interface injection can replace the implementation class of injection ).
You can use many services provided by containers, such as transaction management services and message services. When we use container management, developers no longer need to manually control transactions or process complex transaction propagation.
The container provides support for the singleton mode, so developers no longer need to write their own implementations.Code.
Container providesAOPIt can easily implement functions such as permission interception and runtime monitoring.
Container provides many helper classes,Jdbctemplate, hibernatetemplate.
SpringProvides integration support for mainstream application frameworks, such as integration.Hibernate, JPA, strutsTo facilitate application development.
If you useSpring,We also do not need to deal with complicated promotional activities.
The first possible business requirement isUpdateOperation andSaveCao is executing in a transaction
The second possible business requirement, regardlessUpdateOperation logs must be recorded if the operation is successful or not.
Division of lightweight and heavyweight concepts:
It mainly depends on how many services are used. The more services are used, the container should beJavaThe more work you want to do, it will inevitably affect the application release time or test run performance.
ForSpringProvides many services, but is not enabled by default. If only core services are used, they are lightweight. If most services are used, they are heavyweight.EJBThe container is because he thinks that the application providesEJBAll functions in the Specification, so it is a heavyweight.