First, scan the Mapper interface file:
1, Recommended:
In the Application.java startup file, add annotations:
@MapperScan ("Com.xxx.mapper")
2.
@Mapper
Because my mapper is a module, the portal is a module.
Mapper under the Com.xxx.mapper.
The GroupID of the portal is com.xxx so that it can be scanned @mapper directly.
But
Mybatis-generator generated mapper and not @mapper, even if the toss out, although the efficiency of the operation will not have any impact, start will be slow, wasting time, so not recommended.
Second, scan the Mapper.xml file
1, in application.properties configuration:mybatis.mapper-locations:classpath:mappers/*.xml
2.
<!--Configure the scan package to load the Mapper proxy object--
<bean class= "Org.mybatis.spring.mapper.MapperScannerConfigurer" >
<property name= "Basepackage" value= "Com.xxx.mapper" ></property>
</bean>
@SpringBootApplication
@ImportResource (locations = "Classpath:spring-dao.xml")
public class Portalapplication {
public static void Main (string[] args) {
Springapplication.run (Portalapplication.class, args);
}
}
How to set up a spring boot scan mapper file