@Mapper和@MapperScan注解

1、@Mapper注解:
作用:在接口类上添加了@Mapper,在编译之后会生成相应的接口实现类
添加位置:接口类上面

@Mapper
public interface UserService{
// 相应代码
}

2、@MapperScan
作用:指定要变成实现类的接口所在的包,然后包下面的所有接口在编译之后都会生成相应的实现类
添加位置:是在Springboot启动类上面添加

@MapperScan(value = "com.llkj.project.entity")
@SpringBootApplication
public class LinglingCoreApplication {
    public static void main(String[] args) {
        SpringApplication.run(LinglingCoreApplication.class, args);
    }
}

添加@MapperScan(“com.winter.dao”)注解以后,com.winter.dao包下面的接口类,在编译之后都会生成相应的实现类

3、使用@MapperScan注解多个包
(实际用的时候根据自己的包路径进行修改)

@MapperScan(value = {"com.llkj.project.entity","com.llkj.picc.entity"})
@SpringBootApplication
public class LinglingCoreApplication {
    public static void main(String[] args) {
        SpringApplication.run(LinglingCoreApplication.class, args);
    }
}
原文地址:https://www.cnblogs.com/zhanqing/p/15145874.html