@MapperScan注解使用     DATE: 2024-04-28 02:49:37

@MapperScan注解使用

@MapperScan

作用 :指定要变成实现类的注解接口所在的包,然后包下面的使用所有接口在编译之后都会生成相应的实现类

添加位置  :是在Springboot启动类上面添加,

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

3 、使用@MapperScan注解多个包

(实际用的使用时候根据自己的包路径进行修改)

@SpringBootApplication

@MapperScan({ “com.kfit.demo”,“com.kfit.user”})

public class App {

public static void main(String[] args) {

SpringApplication.run(App.class, args);

}

}

4、 如果dao接口类没有在Spring Boot主程序可以扫描的注解包或者子包下面,可以使用如下方式进行配置:

(没验证过 ,使用不确定能否使用 ,注解或许需要根据自己定义的使用包名进行修改路径)

@SpringBootApplication

@MapperScan({ “com.kfit..mapper","org.kfit..mapper”})

public class App {

public static void main(String[] args) {

SpringApplication.run(App.class, args);

}

}