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);
}
}
Similar Posts:
- Container Cannot Find bean, Field usersMapper in com.imooc.impl.UserServiceImpl required a bean of type ‘com.imooc.mapper.UsersMapper’ that could not be found.
- SpringBoot+Mybatis-plus multi-module project startup Error: xxxmapper or basemapper cannot be found
- Springboot + Maven multi module project startup Error: XxxService cannot be found
- [Solved] Swagger Error: Failed to start bean ‘documentationPluginsBootstrapper’
- Spring boot trample log (@ springbootapplication conflicts with @ componentscan)
- Consider defining a bean of type ‘xxx’ in your configuration. Autowired(required=true)
- [Solved] Spring Boot Startup Error: DataSourceProperties$DataSourceBeanCreationException
- Spring cloud uses feignclient to start and report an error
- nested exception is org.apache.ibatis.binding.BindingException: Invalid boun
- SpringBoot Frame: Failed to determine a suitable driver class [How to Solve]