autowire byType vs byName

I was reading folowing lines and I did not understand clearly.

By using byName autowiring, you are telling the container to consider all properties
of the CourseServiceImpl and look for beans declared with the same name as
the property. In this case, two properties, courseDao and studentService, are eligible
for autowiring through setter injection. If beans are declared in the wiring
file with the names courseDao and studentService, those beans will be wired to
courseDao and studentService, respectively.Autowiring using byType works in a similar way to byName, except that instead of
considering a propertys name, the propertys type is examined. For example, if the
courseService beans autowire is set to byType instead of byName, the container will
search itself for a bean whose type is matches
Any ideas, resources,sample code,links, highly appreciated. thanks in advance.
LVL 7
gudii9Asked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:
I think this is a good explantion of autowiring byName and byType:

Autowiring by property name. This option will inspect the BeanFactory and look for a bean named exactly the same as the property which needs to be autowired. For example, if you have a bean definition which is set to autowire by name, and it contains a master property (that is, it has a setMaster(...) method), Spring will look for a bean definition named master, and use it to set the property.

Allows a property to be autowired if there is exactly one bean of the property type in the BeanFactory. If there is more than one, a fatal exception is thrown, and this indicates that you may not use byType autowiring for that bean. If there are no matching beans, nothing happens; the property is not set. If this is not desirable, setting the dependency-check="objects" attribute value specifies that an error should be thrown in this case.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.