What is the difference between spring factory-method and factory-bean?

前端 未结 6 2033
小鲜肉
小鲜肉 2021-02-02 10:28

I am new Springs. In Bean tag I found factory-method and factory-bean Attributes. What is the difference between factory-method and factory-bean?

I am using factory-meth

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 10:41

    You can find documentation about this here. See section 3.2.3.2 and 3.2.3.3.

    factory-method is used to point to a static method in legacy code that can be used to create a bean.

    Quite similar to using a static factory method to create a bean, is the use of an instance (non-static) factory method, where a factory method of an existing bean from the factory is called to create the new bean.

    This is what factory-bean is for.

提交回复
热议问题