如果在接口类上添加了@Mapper,在编译之后会生成相应的接口实现类
@Mapper
public interface UserDAO {
//代码
}
如果闲麻烦,不想在每个mapper上加@Mapper注解,就可以在启动类上加@MapperScan注解并标注需要编译生成实体类的路径(“cn.wenham.dao”)的注解。这样在编译之后都会生成相应的实现类。
@SpringBootApplication
@MapperScan("cn.wenham.dao")
public class SpringbootMybatisDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootMybatisDemoApplication.class, args);
}
}
public interface UserDAO {
//代码
}