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 Bean.
From the beginning, we know that the essence of mutual calls between components in Java applications can be summarized as dependency. Depending on the injection m
class= "Org.han.action.LoginAction" scope= "singleton" > Before spring2.0 beans had only 2 scopes: Singleton (singleton), Non-singleton (also known as prototype), Spring2.0 later, added session, request, global Session three beans dedicated to the context of the Web application. Therefore, by default Spring2.0 now has five types of beans. Of course, Spring2.0 the design of the bean type, and design a flexible
@Bean is a method-level annotation that is used primarily in @configuration annotated classes, or in @component annotated classes. The ID of the added bean is the method nameDefining beansHere's an example from @configuration.@Configuration Public class AppConfig { @Bean public transferservice transferservice () { return New Transferserviceimpl (
First, build the spring environment:With the introduction of the jar package in the Lib directory and add to path, it is not too much to say.Ii. three ways to instantiate a bean:First, let's start by writing two Java classes:Interface class:Public interface Personservice {public abstract void Save ();Implementation class:public class Personservicebean implements Personservice {@Overridepublic void Save () {System.out.println ("I Am the Save () method") ;}}Write a test method again:public class S
How to use the scope of spring:The scope here is used to configure the scope of the spring bean, which identifies the scope of the bean.Before spring2.0, the Bean had only 2 scopes: Singleton (single example), Non-singleton (also known as prototype), after Spring2.0, added session, request, global Session three beans dedicated to the context of the Web application. Therefore, by default Spring2.0 now has fi
Bean is the basic unit of spring management. In spring J2EE applications, all components are beans. Beans include data sources, sessionfactory of hibernate, and Transaction Manager. Bean in spring is a very broad concept. Any Java object or Java component can be treated as bean.
Beanfactory --> the most basic interfaces of spring containers. Beanfactory is respon
3.6. Inheritance of bean definitions
The bean definition contains a large amount of configuration information, including container-related information (such as initialization methods, static factory method names, and so on), as well as constructor parameters and property values. A child bean definition is a bean defin
The previous blog introduces the basic concepts and scopes of beans in spring (Spring Reading notes-----The basic concepts of spring bean beans), and now introduces The basic configuration of the Spring Bean . from the beginning we know that the nature of the mutual invocation of each component in a Java application can be summed up as a dependency relationship. Depending on the injection method, theBean 's
Although the world's food culture is different, it is quite consistent that "eating" should be "natural and healthy. One of the world's "natural, healthy" Foods leads the cool, is bean sprout from China. According to reports, bean sprouts are very popular abroad. Many countries in Europe, America, Asia, and Hong Kong, Macao, and Taiwan have bean sprout factories.
How to use the scope of spring:This scope is used to configure the scope of the spring bean, which identifies the scope of the bean.Before spring2.0 beans had only 2 scopes: Singleton (singleton), Non-singleton (also known as prototype), Spring2.0 later, added session, request, global Session three beans dedicated to the context of the Web application. Therefore, by default Spring2.0 now has five types of beans. Of course, Spring2.0 the design of the
SpringMVC source code deep parsing (context: component-scan) (scan and register annotation Bean)
Some of our SpringMVC development projects use annotations and XML to configure beans, which have their own advantages. XML is often used for data source configuration, the services dependent on the control layer often use annotations (which won't be changed during deployment). We often use annotation @ Component as a general annotation and @ Controller as
The factory bean here is different from the previous example factory method to create bean, or the static factory method to create Bean Factory: the previous factories are standard factory models, spring is only responsible for calling factory methods to create bean instances.Factory BeanIs a special
With the applicationProgramAs the scale increases, the growth of spring configuration files is faster. When there are more and more components in the application, the bean configuration in the spring configuration file also increases greatly, and a phenomenon will gradually emerge: a large number of bean configurations are identical, only a small number of configurations are different. Is there a way to sim
Traditional applications can instantiate beans by reflection, and the spring IOC container needs to use a reflection mechanism to create beans based on the configuration metadata defined by the bean. There are several ways to create a bean instance in the Spring Ioc container:Instantiating a bean using a constructorInstantiating a
The bean creation process:Spring Beanfactory's Factory mode implementation:Parse People o = (people) Factory.getbean ("P");Because the map has an object type, you need to force the type conversion when you remove itBean's life cycle:The purpose of spring aware is to let the bean get the service of the spring container, and the bean inherits Applicationcontextawar
keyword: Spring IOC bean's scope attribute value: Prototype and Singleton
Spring IOC Bean's scope attribute value: Prototype and Singleton
If the specified bean is scoped to scope= "prototype" in
Later life management, spring no longer manages the lifecycle of these beans. If the scope is set to Scope= "Singleton", the
The bean is placed into the cache pool of the spring IOC container, and the
Beanpostprocessor (Bean post processor) is commonly used to modify the value inside the bean, implement the bean dynamic proxy, and so on.
Both Beanfactorypostprocessor and Beanpostprocessor are the extension points exposed when spring initializes the bean. But what difference do they have?The graph of the Understand
Spring Bean life cycleIn traditional Java applications, the Bean life cycle is very simple.Java's keyword new is used to instantiate a bean (perhaps he is a non-serialized). That's enough.Instead, the bean's life cycle is more granular in the spring container.Understanding the life cycle of the spring bean is important
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.