Spring also has an abstract bean. You only need to set the abstract attribute to true in the configuration file. It does not configure the class attribute because it will not be instantiated. When the bean of another spring inherits the abstract bean, You need to configure i
In Spring configuration, the bean class uses the factory Bean meaning for parsing. springbean
Parsing the meaning of factory bean used by Bean class in Spring Configuration
Beautiful Life of the sun and fire god (http://blog.csdn
Spring bean dependency injection, bean assembly and related annotations, springbeanDependency Injection
Spring provides the following two methods for dependency injection:
Property-based Setter method Injection
Constructor Injection
Setter method Injection
Example:
public class Communication { private Messaging
In general, we register a bean in spring and directlyid= "WebSocket" class= " Com.sdyy.common.spring.websocket.WebsocketEndPoint "/>This creates an object bean for us, using the Websocketendpoint construction method (which is no parameter).———————————————————————————— Dividing line —————————————————————————————————————————————But there is another way to register
Common annotations for Spring beans@Component: usually annotations, available for any bean@Repository: Typically used to annotate the DAO layer, which is the persistence layer@Service: Typically used to annotate service tiers, or services tiers@Controller: Typically used to annotate the controller layer, which is the control layerAutomatic detection of classes and the registration of beansDefining beansThe
Assembly also has a unique drawback: when there are multiple constructors, spring cannot choose exactly which constructor to initialize, so it also runs out of the exception.
AutoDetect: The best self-assembly.When spring Initializes a bean with the autowire= "AutoDetect" set, it is first assembled with a constructor. If there are multiple beans or cons
http://blog.csdn.net/anyoneking/article/details/5182164In spring's bean configuration, there are two scenarios:[XHTML]View Plaincopy
Bean id="Testmanager" class="Com.sw.TestManagerImpl" scope= "singleton"/>
Bean id="Testmanager" class="Com.sw.TestManagerImpl" scope= "prototype " />
Of course, the scope has more than two values, in
. Annotationconfigapplicationcontext preparerefresh Info: refreshing org. springframework. Context. Annotation. Annotationconfigapplicationcontext@203e25d3:startup Date [Thu : Each CST 2016] ; root of context hierarchyspring container start initialization ... 2. The @Bean is labeled on the method (the method that returns an instance), equivalent to the spring XML configuration file , which functions as: re
1. servlet container
The entire servlet lifecycle seems to be handled by the servlet container.
If you place it in a spring container for creation, the servlet object can be created by the spring container, but the servlet container may not know that the servlet exists because it is not in its container.
Therefore, the servlet should be handed over to the Web server and not to
Diagram of the spring container, bean configuration information, bean implementation class, and application four:Bean configuration information defines the implementation and dependencies of the bean, and the spring container establishes the
Reference: http://hi.baidu.com/victorlin23/blog/item/45ba7d1b2ccbced8ad6e7595.html
The bean defaults to Singleton.
If you do not want a singleton, the following configuration:
Singleton is the configuration of this bean is a singleton, if not write, is the default value of True.
Annotations:
Spring Bean life c
The previous blog introduced the basic concepts and scopes of Bean in Spring (Spring Reading Notes ----- basic concepts of Bean in Spring). Now we will introduce the basic configurations of Spring
All Spring beans are single-instance by default. If multiple instances are required, the configuration is as follows:
Scope
Definition
Singleton
In each spring container, a Bean defines only one object instance (default)
Prototype
Allow beans to be instantiated any time
Reqyest
In an HTTP request, each
Original: http://selppay-gmail-com.iteye.com/blog/7632631. Spring Bean definationIn general, we define and apply beans using bean IDs, but today I have this definitionXML code
bean id = "writeservice" class = "Aserviceimp, Bserviceimp, cserviceimp"
name = "Aservice, bservice, cservice" Init-method = "i
applicationcontext is initialized or refreshed. Initialization means that all beans are loaded, Singleton is pre-instantiated, and applicationcontext is ready.
B. contextclosedevent
Events sent when the context is ended using the close () method of applicationcontext. This means that Singleton is destroyed.
C. requesthandledevent
A Web-related event tells all beans that an HTTP request has been responded (this time will be sent after a request ends -). Note: This time can only be applied to Web
Spring learning notes -- 02 Bean naming and instantiation, learning notes bean
I. Bean naming
In the previous article, IoC is a container for Bean management. In most cases, beans are configured through XML files. The Bean naming
The Bean class in Spring configuration uses the meaning of the factory bean to parseThe beautiful Life of the Sun Vulcan (http://blog.csdn.net/opengl_es)This article follows "Attribution-non-commercial use-consistent" authoring public agreementReprint Please keep this sentence: Sun Vulcan's Beautiful Life-this blog focuses on Agile development and mobile and IoT
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.