Social Media

Spring Autowiring

There is an eternal struggle in Spring as to whether xml or annotations are best. The truth is there is no “best” solution and sometimes xml is best, and sometimes annotations are best.

There are 4 types of autowiring –

  • byName – Match by name or id. If no match then unwired
  • byType – Match by type. If no match the unwired
  • constructor – Match constructor arguments
  • autodetect – constructor then byType

The default-autowire is none

About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About or on my consultancy website Glendevon Software

follow me on:

Leave a Comment: