springboot study some conclusions about the @ComponentScan and @MapperScan

The main program plus @componentScan + DAO layer plus @ Mapper not visit

The main program plus @ componentScan + DAO layer plus @ the Component or
@ the Component ( "userDao" ) not visit

The main program plus @ componentScan + DAO layer plus @ Repository or @ Repository ( "userDao") not visit

The main program plus @ MapperScan ( "com.jay.dao") + DAO-plus @ Mapper access to

The main program plus @ MapperScan ( "com.jay.dao") + DAO-plus @ the Component access to

The main program plus @ MapperScan ( "com.jay.dao") + DAO-plus @ the Repository or @ ** Repository ( "userDao") ** access to

Therefore the main added only @ can MapperScan ( "com.jay.dao") automatically scan the dao injection layer and
Here Insert Picture Description

Dao layer but not add or @Mapper @Repository @Component or not to see the main program and a member (though springboot implicit scanned and injected)
Figure:

It is recommended plus @Mapper or @Repository in Dao layer

And thus lead to a problem:
the difference between the @MapperScan and @ComponentScan

The difference between spring and @ComponentScan of @MapperScan

Spring Boot common annotation simple order (including: @ ComponentScan, @ MapperScan, @ Controller, @ RequestMapping, @ Autowired, @ Repositor etc.

Maven dependency delete unused

java.lang.NoSuchMethodError: org.springframework.core.ResolvableType.forInstance error solution

I think it is to see the annotation name @ComponentScan it really is scanned to but just know he's a Component but did not know it acts dao layer in a web project
and @MapperScan then see the name that he is the way in accordance with the scan Mapper layer not only to the scanning and injection success dao layer
welcomed the discussion. . .

Published 81 original articles · won praise 19 · views 3629

Guess you like

Origin blog.csdn.net/c22cxz/article/details/104314175