Mapa mental
Spring

Contenido del mapa
Spring
configuration
- pom
- build tag to change compiler (java version)
- maven-compiler-plugin
- configuration
- java version
- configuration
- maven-compiler-plugin
- add spring dependency
- build tag to change compiler (java version)
- pom
xml configuration
- application context
- sort of Hash Map
- can be a registry
- multiple types of xml available
- properties defined by its schema type
- beans: allow us to defien multiple bean
- properties defined by its schema type
- namespaces
- acts as a dictionary for the properties we can inject into a bean
- need to create a context in the main method
- application context
beans
- are essentially classes
- replace keyword new
- injection
- setter
- define the properties inside the bean in java code
- in xml, bind the property with its bean
- name based
- can mix both
- constructor
- index based
- need to define constructor for each situation
- modify xml and bean
- setter
- autowire
- 4 ways
- by type
- as by name, match the bean property with the bean declared in xml, using the class type.
- by name
- uses set method, and tries to match the bean declared inside xml with the "setName method" inside the bean using the name
- constructor
- no
- by type
- 4 ways
- 5 possible scope for beans
- Singleton
- creates a single instance of a bean for each container
- use @Scope("singleton" or ConfigurableBeanFactory.SCOPE_SINGLETON)
- creates a single instance of a bean for each container
- prototype
- guarantee an unique instance per bean request
- webScopes
- Request
- creates a bean per http request
- Session
- creates a single bean per live session
- globalSession
- creates a single bean per application
- Request
- Singleton
- are essentially classes
goals
- separate configuration from logic (separation of concerns)
- no need to recompile the whole project
- separate configuration from logic (separation of concerns)
Dependency Injection types
- Annotation configuration
- aplicationContext.xml
- uses the beans schema
- includes a component scanner
- includes namespaces context (non version to keep compatibily)
- Stereotype annotations
- @Component
- any POJO (meant to be a bean)
- @Service
- bussiness logic layer
- the 3 define the name bean in parentesis
- bussiness logic layer
- @Repository
- Data Acess tier
- semantically they are the same (service and repository extends component and dont add any feature, it`s about how you think of them and use them)
- allow us to mark POJOS as Beans
- @Component
- Autowire
- Can autowire at 3 places
- member variables
- should be avoided, makes the testing harder
- constructor
- the 3 approches uses the @autowired before the definition
- setter
- member variables
- Can autowire at 3 places
- aplicationContext.xml
- java configuration
- uses java instead of xml
- called AppConfig and define the beans?
- there is no need to have an applicationContext
- uses java instead of xml
- called AppConfig and define the beans inside
- uses the class level annotation @Configuration and @Bean
- uses java instead of xml
- injection
- setter injection
- need to define a setter inside the class where beans will be injected, which will be called in "AppConfig"
- construction injection
- works as setter injection, but need a constructor instead
- setter injection
- Autowire
- is available, need to add a @ComponentScan at the top of AppConfig
- there is no need to define beans in AppConfig (can be empty except for the Scanner)
- Must use @Autowired just above the setter
- and use stereotype tag for @Service or @Repository when defining a class
- uses java instead of xml
- Annotation configuration
properties
- abstact configuration and defined in one file
- types
- xml
- need to
- create a properties file
- define its path in the application context.xml for the properties file
- Define the property and its value inside the bean
- create an attibute and its setter inside the bean
- annotation
- same steps just need to add @value in bean attibute, and annotation in application context
- need to
- java config
- xml
- types
- abstact configuration and defined in one file
Imágenes y archivos del mapa
Información
- Descripción
- Mapa Mental sobre Spring, creado por Jorge Celis el 01/10/2019.
- Creado por
- Jorge Celis
- Visitas
- 0
- Valoración








