Two ways to implement Spring Boot’s scanmapper interface class

1. Method 1: use annotation @mapper

Add annotation on all mapper interfaces@ mapper; spring boot starts annotation auto scanning.

The following is the Default scan configuration of spring boot. When auto scan is started, all custom beans will be automatically scanned

2. Method 2: use annotation @mapperscan

Add the annotation @mapperscan to the springboot startup class to mark the package path of Dao. Once and for all, recommended!!

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@MapperScan(basePackages = {""})
public class MpServiceProviderApplication {
    public static void main(String[] args) { .class, args);

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *