@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:
- Https://www.cnblogs.com/ClassNotFoundException/p/6928205.html
- Https://zhidao.baidu.com/question/359557916.html
@lazy Annotations of Spring annotations