mapper接口是指操作数据库的接口,如UserMapper
UserMapper.xml
实现UserMapper
中操作数据库的sql语句编写
application.yml
中mybatis.mapper-locations
指定操作数据库的mapper.xml文件所在位置,如mybatis.mapper-locations: classpath:mybatis/mapper/*.xml
@Mapper
指定哪些是可以操作数据库的类,并把它放入spring容器中
如果需要写多个@Mapper
,可以在springboot启动类使用@MapperScan("xxx")
注解,xxx
指的是多个需要使用@Mapper
的类所在的包