Chapter One Spring Tour
Pojo:plain old Java object Simple Java objects
Di:dependency Injection Dependency Injection
Constructor injection: passed in as a constructor parameter at construction time
Private Quest Quest; Public braveknight (Quest Quest) { this. Quest = Quest;}
Where quest is an interface used to achieve loose coupling .
You can use mock implementations when testing. As follows:
Quest mockquest = mock (Quest. Classnew braveknight (mockquest);
Assemble wiring: Create collaborative behavior between components.
XML Configuration Assembly
<id= "Quest" class= "Test." Slaydragonquest "/><id=" Knight " class= "Test. Braveknight "> <ref=" quest "/> </bean>
Load a bean's definition by applying context (application context)
New Classpathxmlapplicationcontext ("Knight.xml"= (Knight) Context.getbean ("Knight");
Aop:aspect-oriented Programming Application slice programming-separates into reusable components.
Spring container: Bean factories, simplest container
Application Context: Provides application-oriented services based on bean factories.
XML file under the classpathxmlapplicationcontext--class path
filesystemxmlapplicationcontext--an XML file under an absolute path
XML files under the Xmlwebapplicationcontext--web application
Spring Framework (classified as miscellaneous, common as below)
1. AOP Modules
2. DAO module (data Access Object)
Orm:object-relational Mapping Object Relational mapping
Map relational data in relational databases to objects in a program.
3. Web Module
4. Spring MVC
*************************************************************************************
Chapter II Assembly Bean
Constructor injection
<id= "Duke" class= "Test." Duke "> <value="/>"<!-- Note If you inject another bean, you need ref, not value-</bean>
Creating beans from engineering methods
--You can configure a class with no public constructors as a bean
<id= "Singleton" class= "Test." Singleton "factory-method=" getinstance"/>
Scope of the Bean
Singleton (default) A bean definition corresponds to an object instance in each spring IOC container.
prototype A bean definition corresponds to multiple object instances.
request in an HTTP request, a bean definition corresponds to an instance, that is, each HTTP request will have its own bean instance, which is created from a bean definition. This scope is valid only in the Web-based spring ApplicationContext
scenario.
session in an HTTP Session
, a bean definition corresponds to an instance. This scope is valid only in the Web-based spring ApplicationContext
scenario.
global-session in a global HTTP Session
, a bean definition corresponds to an instance. Typically, this is only valid when using the Portlet context. This scope is valid only in the Web-based spring ApplicationContext
scenario.
Spring in Action (third edition) reading notes