BEANFACTORY Method for generating Bean in Spring

xiaoxiao2021-03-06  55

According to the configuration of bean in Spring, BeanFactory generates Bean's method to divide three:

1) Direct constructing this is the most common method, in which case we need a default constructor and the corresponding setters / getters method. For example: What should be noted that we can deliver parameters (with preperties tags) for the getter / setter method, or to deliver parameters for constructor (with a constructor tag).

2) Use static factory methods such as: This is required to have a static method CreateInstance

3) Non-static factory method here However, there must be no "class" tag, factory-bean is BeanFactory, Factory-Method is its non-static method, pay attention, MyFactoryBean can manage and configure through the container.

转载请注明原文地址:https://www.9cbs.com/read-114159.html

New Post(0)