Leading: Start learning Spring core ideas and learn with a cottage Lite spring code.Content: 1. Propertyvalue-Save Property Injection information. 2.autowirecapablebeanfactory-can automatically assemble the beanfactory.Here we redefine the beandefinition, add the attribute list to this field, we will add additional attributes for the
I. knowledge points
If you want to declare beans from an object attribute or nested attribute (that is, the attribute path) in the Spring IoC container, you can use the built-in factory bean propertypathfactorybean or
Ii. Sample Code
Create a productranking class
package com.jackie.codeproject.springrecipesnote.springadvancedioc;/** * @author huangfeifei * */public class ProductRanking {private Product be
Bean definition reuse involves two steps:
1. Define a parent bean.
2. Make the child bean inherit the parent bean and add its own property.
The definition of a parent bean is generally as follows:
The bean label abstract att
. This scope is only valid in the Web-based Spring context (such as Spring MVC ).
Global-session
In a global HTTP Session, each Bean definition corresponds to an instance. This scope is only valid in the Portlet context.
Bean initialization and destruction
Bean
id and use the rest as the default Bean name. If the ID attribute does not exist, search by Name attribute (use the first NAME as the default Name). If neither ID nor NAME exists, search by class Name.
Id ----------> name ---------------> Class name
Bean alias:
Use the alias attribute to specify:
2.3 create a Bean
Create XML file ---- write configuration inform
Bean configuration in Spring and Spring Bean Configuration
Original works, can be reproduced, but please mark the source address http://www.cnblogs.com/V1haoge/p/5859556.html
1. Bean configurations are generally configured in XML files.
2.
Spring -- configure bean through annotation, spring -- bean
Spring configures bean through AnnotationBean configuration based on AnnotationConfigure bean
Spring basics-automated bean assembly and spring basics bean
As mentioned in the previous blog post about Spring's IOC container, although the container is powerful, the container itself is just an empty shell. We need to take the initiative to put the Assembly object and tell it the collaboration relationship between
Bean of Spring Core Components and spring core beanBeanBean class hierarchy of Spring Core Components
BeanFactory is the top-level interface of Bean, where the source code is
/spring-framework/
Spring Bean loading and Spring Bean LoadingSpring bean loading principle: After bean creation is complete, the ObjectFactory of bean creation will be exposed early and added to the cach
Beans are ubiquitous in spring and SPRINGMVC, it's important to put this concept into context, and here's what I think:First, what is a bean?1, Java object-oriented, the object has methods and properties, then you need an object instance to invoke methods and properties (i.e. instantiation);2. All classes that have methods or attributes need to be instantiated to
Beans are ubiquitous in spring and SPRINGMVC, it's important to put this concept into context, and here's what I think:First, what is a bean?1, Java object-oriented, the object has methods and properties, then you need an object instance to invoke methods and properties (i.e. instantiation);2. All classes that have methods or attributes need to be instantiated to
Spring (4) Bean injection (Spring Bean injection)1. constructor Injection
Definition: You can use constructors to set dependencies.
Advantages and disadvantages:
Complete dependency creation while constructing objects
If there are many associated objects, you have to add too many parameters to the constructor.
Base ind
First, the bean definitionThis is one of the simplest Bean definitions. It is similar to calling a statement:Memoryuserdao Userdao = new Memoryuserdao ().The id attribute must be a valid XML ID, which means that it must be unique throughout the XML document. It is a "lifetime code" for a Bean. You can also use the Name property to define one or more individual na
Sometimes you need to get a spring bean object on your own as needed in your new object, or in some Util method or property, to do some work, but because your new object and Util method are not managed by spring, if you use it directly on the property that you depend on @Autowiredyou will be able to report an error that cannot be injected, or it will not be repor
Spring bean loading and Spring bean LoadingSpring instantiates the Beanbean loading process through reflection:
Convert the corresponding beanName: remove the modifier of FactoryBean (remove "")
Try to load the singleton from the cache (in map)
Bean instantiation (th
The design principle of spring is to use as many instances as possible and as many single-State instances as possible, which can be seen from its bean configuration file. However, sometimes injection is not the best solution, especially for the processing of legacy classes. Static classes may be a better solution, because static classes do not need to be injected, there is no need to change the original cod
Spring Boot for JSP development dynamically creates Bean and Spring Bean
Spring Boot for JSP development dynamically creates beans
1. Create an Import using annotation @ Import
A. Create the MyImportBeanDefinitionRegistrar registration center.
Java code
import org.springfram
Go to: how to obtain the bean managed by Spring and the bean managed by spring
Original article:Http://blog.csdn.net/a9529lty/article/details/42145545
1. When loading in servlet mode,[Web. xml]Xml Code
SpringMVC
Org. springframework. web. servlet. DispatcherServlet
ContExtConfigLocation
Classpath *:/springMVC.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.