1. What is Spring?
Struts is the web framework (php/action/actionform)
Hibernate is the ORM Framework (the framework of objects and relational mappings, in the persistence layer)
Spring is a framework for container frameworks that configure beans and maintain relationships between beans
Bean (is any object in Java javabean/service/action/data source/dao) ROC (Control inversion) di (dependency injection)
2. Develop a spring project
(1) Introduction of the spring development package, the minimum configuration Spring.jar, the package to the common jar is included, but also to write a log packet Commons-logging.jar
Create a core file for spring Applicationcontext.xml (Hibernate has core file hibernate.cfg.xml)
(2) Struts core file Struts.config.xml The file is typically in the SRC directory
(3) Configuring the bean (service/dao/daomain/action/data source) in the container file
<!--bean element's role is that when our spring framework loads, Spring automatically creates a bean object and puts it in memory equivalent to UserService userservice=new userservice () and
<bean id= "UserService" class= "Com.service.UserService" >
<property name= "Name" >//
<value> Hanshunping </value>//userservice.setname ("Hanshunping");
</property>//
<!--quoting Bybservice bean--> in UserService
<property name = "Byeservice" ref= "Bybservice" >
</bean>
<bean id= "Bybservice" class= "Com.service.BybService" >
<property name= "name" value= "Xiao Ming" >
</bean>
1. Get spring ApplicationContext Object (Container object)
ApplicationContext ac = new Classpathxmlapplicationcontext ("Applicationcontext.xml");//File is loaded
UserService US = (userservice) ac.getbean ("UserService");//Remove UserService Reference Object
Us.sayhello ();
From act represents the ApplicationContext container
Bybservice Bybservice = (bybservice) ac.getbean ("Bybservice");
Bybservice.saybye ();
3.
Spring is actually a container framework that can be configured with a variety of beans and can maintain the bean-to-bean relationship, and when we need a bean, we can Getbean ().
What is the IOC?
IOC (inverse of controll) control inversion is the transfer of the right to create objects (beans) and maintain objects (beans) from the program to the Spring container (applicationcontrol.xml)
DI: (Dependency Injection) Dependency injection: Actually DI and IOC are the same concept, and Di is more capable of representing the core of spring.
Hanshunping Spring Notes First Lecture