Introduction of several properties based on springioc bean

1.lazy-init="false"

The default value is false, which means that these classes will be loaded as soon as the spring container starts A little bit is to find the bean related errors in time, because the bean will be created when the spring container is started. If there are any errors in the bean, they will be reported. The disadvantage is that if the bean object costs a lot, it will occupy memory in advance

If set to true, it will not be created until the spring container gets 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, pay attention to thread safety and avoid attribute sharing

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

3.init-method=""

After executing the constructor of the bean, invoke the specific method of the bean before calling.

4.destory-method=""

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

The above introduction to several properties based on springioc beans is all that Xiaobian has shared with you. I hope it can give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>