In Spring, what do you mean by Auto Wiring?

Answered

In Spring, what do you mean by Auto Wiring?

Ninja Asked on 17th September 2018 in Spring.
Add Comment
1 Answer(s)
Best answer

Auto wiring is a capability by which Spring container is able to establish relationships between collaborating beans without the need to provide explicit wiring instructions through <constructor-arg> and <property> elements on bean definition (XML) files.

This helps in reducing the amount of XML configurations. The auto wiring functionality has five modes:

• no – This is the default setting which means no auto wiring. Explicit bean reference should be provided through the XML file.

• byName – Auto wiring by property name. When this option is used, the container attempts to look for a bean that has the same name as the property of the auto wired bean.

• byType – Auto wiring by property type. The container attempts to match all properties of the auto wired bean with beans whose types are compatible to the properties.

• constructor – This is similar to byType but applies to constructor. The container attempts to match up a constructor of the auto wired bean with beans whose types are assignable to the constructor arguments

• autodetect – The container attempts to apply ‘Auto wiring by Constructor’ first if it fails, it applies ‘Auto wiring byType’.

Ninja Answered on 17th September 2018.
Add Comment