What in the world are Spring beans?

前端 未结 12 1469
谎友^
谎友^ 2020-11-28 00:19

I am yet to find a high-level definition of Spring beans that I can understand. I see them referenced often in Grails documentation and books, but I think that understanding

12条回答
  •  清歌不尽
    2020-11-28 00:41

    For Spring, all objects are beans! The fundamental step in the Spring Framework is to define your objects as beans. Beans are nothing but object instances that would be created by the spring framework by looking at their class definitions. These definitions basically form the configuration metadata. The framework then creates a plan for which objects need to be instantiated, which dependencies need to be set and injected, the scope of the newly created instance, etc., based on this configuration metadata.

    The metadata can be supplied in a simple XML file, just like in the first chapter. Alternatively, one could provide the metadata as Annotation or Java Configuration.

    Book: Just Spring

提交回复
热议问题