What do you mean by Auto Wiring?

Technology CommunityCategory: SpringWhat do you mean by Auto Wiring?
VietMX Staff asked 3 years ago

The Spring container is able to autowire relationships between collaborating beans. This means that it is possible to automatically let Spring resolve collaborators (other beans) for your bean by inspecting the contents of the BeanFactory. The autowiring functionality has five modes.

  • no: This is default setting which means no autowiring. Explicit bean reference should be used for wiring.
  • byName: It injects the object dependency according to name of the bean. It matches and wires its properties with the beans defined by the same names in the XML file.
  • byType: It injects the object dependency according to type. It matches and wires a property if its type matches with exactly one of the beans name in XML file.
  • constructor: It injects the dependency by calling the constructor of the class. It has a large number of parameters.
  • autodetect: First the container tries to wire using autowire by constructor, if it can’t then it tries to autowire by byType.