What in the world are Spring beans?

前端 未结 12 1454
谎友^
谎友^ 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:51

    In terms of a Spring boot application, a bean is simply a Java object which is created by Spring framework when the application starts.

    The purpose of the object can be pretty much anything - a configuration, a service, database connection factory etc. - Spring doesn't really care.

    Most beans depend on other beans to work, for example an entity manager might need a database connection. Spring framework is able to figure out how the beans should be wired together automatically. From your point of an application developer, you just have to declare the beans you need and they "magically" appear in your application ready to use.

提交回复
热议问题