Home  >  Article  >  Java  >  Introducing the common properties of springioc beans

Introducing the common properties of springioc beans

巴扎黑
巴扎黑Original
2017-09-11 11:30:451103browse

The following editor will bring you an introduction to several properties based on springioc beans. The editor thinks it’s pretty good, and now I want to give it to you and give it as a reference. Let’s follow the editor and take a look.

1.lazy-init="false"

The default value is false, which refers to the bean The creation timing of the spring container will load these classes as soon as it starts. One of the advantages is to find bean-related errors in time. Because the spring container starts, the beans will also be created. If there are any errors in the beans, they will be reported. The disadvantage is that if the overhead of the bean object If it is larger, it will occupy memory in advance.

If set to true, it will not be created until the spring container obtains the object of the bean. The advantages and disadvantages are opposite to false

2.scope="singleton"

The default value is singleton, which means that the bean object in the spring container is singleton by default. At this time, due to thread safety issues, Avoid attribute sharing

If set to prototype, it means multiple instances. At this time, no matter lazy-init is invalid, it will be lazy loading.

3.init-method=""

Called after executing the bean's constructor and before calling the specific method of the bean

4.destory-method=""

Called when the spring container is closed or destroyed (singleton mode only)

The above is the detailed content of Introducing the common properties of springioc beans. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn