springboot automatic assembly Introduction

The so-called automatic assembly, is autowire.

How to activate automatic assembly it?

Method One: @EnableAutoConfiguration or @SpringBootApplication, written on @Configuration class.

Method two: xml for the <context: component-scan>, using loading ClassPathXmlApplicationContext

Method three: For @ Import, @ ComponentScan, using AnnotationConfigApplicationContext registration.

Automatic assembly strategies have those?

byType (default)

byName

constructor

 

@AutoWired

Defaults the byType, if there are multiple instances of this type, the use byName try to match, if not also byName determination, and may be determined by @Primary @Priority.

 

Guess you like

Origin www.cnblogs.com/yaoyuan2/p/11705225.html