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 org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@EnableDiscoveryClient
@MapperScan(basePackages = {"com.mp.service.provider.dao"})
@SpringBootApplication
public class MpServiceProviderApplication {
public static void main(String[] args) {
SpringApplication.run(MpServiceProviderApplication .class, args);
}
}
Read More:
- Spring boot uses configuration interface webmvcconfigurer to solve cross domain problems
- Spring-boot Use dubbo Error: ERROR 8404 o.s.boot.SpringApplication:Application run failed
- Tk.mapper Common mapper Error: Error creating bean with name ‘commonMapper‘ defined in file xxx
- Dyf Spring boot startup error: NoSuchBeanDefinitionException
- [How to Fix] Spring boot startup error: could not resolve placeholder
- New Spring boot startup error Failed to auto-configure a DataSource
- Spring Boot Druid Error: discard long time none received connection
- [neo4j] error report when visiting neo4j in spring boot project
- Causes of error in data transmission from spring boot to JSON
- [Solved] spring boot – JPA–H2 Error: H2 error: “Syntax error in SQL statement … expected identifier“
- IDEA generates Spring Boot project error: error: read timed out
- Two Way Communication Error: Function two_way_comm_post_message / two_way_comm_post_message_ex faile
- [Go] Solve the empty interface interface{} cannot use (type []string) as type []interface {}
- [Solved] Failed to bind properties under ‘spring.datasource.type‘ to java.lang.Class<javax.sql.DataSource>
- [Solved] spring boot security Start Error: ‘login.html?error‘ is not a valid redirect URL
- Error running ‘PigSellCabinetApplication’: Command line is too long. Shorten command line for PigSellCabinetApplication or also for Spring Boot default configuration
- [Solved] Springboot Reflection calls ServiceImpl Error: java.lang.NullPointerException, mapper is null
- [Solved] Doris BrokerLoad Error: Scan bytes per broker scanner exceed limit: 3221225472
- [Solved] hcitool Error: Set scan parameters failed: Operation not permitted
- SpringBoot uses MyBatis error: Error invoking SqlProvider method (tk.mybatis.mapper.provider.base.BaseInsertProvider.dynamicSQL)