Record three ways SpringBoot integration Mybatis configuration

method one

This way is very simple, only need Mapper接口the add a comment @Mapperto.
Here Insert Picture Description

Second way

Hey, this approach is also very simple, only need 启动类plus a @MapperScan(“com.rong.blog.mapper”)can comment.
Here Insert Picture Description

Three ways

Write yourself in a configuration class.
Here Insert Picture Description


Note Yo, none of the above are several ways to use @Repositoryannotations, after Baidu out the specific reasons plus.

Without @Repositorywhen injected Mapper comment on IDEA compiler, an error, however 并不是真的错误. If you do not want this error occurs, you can add.
Here Insert Picture Description

Published 141 original articles · won praise 131 · views 210 000 +

Guess you like

Origin blog.csdn.net/qq_41621362/article/details/105213553
Recommended