@lazy Annotations of Spring annotations

Source: Internet
Author: User

@Lazy is used to specify whether the bean cancels pre-initialization. Mainly used to decorate the spring bean class to specify the pre-initialization behavior of the bean.

When you use this annotation, you can specify a Boolean value property that determines whether to pre-initialize the bean

    • Lazy represents the delay load, lazy=false, non-delay, if object A also has a reference to object B, will be in the XML mapping file A To configure B's object reference, many to one or a pair of more, no delay represents the query out of object A, the B object will also be queried to put in a reference to a object, The B object in a object is a value.
    • Lazy=true representative delay, query a object, will not be the B object is also queried, will only use a object in the B object will go to query, the default seems to be false, you can see the background of the SQL statement changes to understand, generally need to optimize the efficiency of the time will be used
@Lazy (true) @Componentpublicclassimplements  person{    // Codeshere}

@DependsOn is used to force the initialization of other beans. A bean class or method can be decorated, and the annotation can be used to specify an array of strings as parameters, each of which corresponds to a forced-initialized bean

@DependsOn ({"Steelaxe", "abc"}) @Componentpublicclassimplements  person{   //codeshere}

Reference:

    1. Https://www.cnblogs.com/ClassNotFoundException/p/6928205.html
    2. Https://zhidao.baidu.com/question/359557916.html

@lazy Annotations of Spring annotations

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.