直接使用是会报错的 甚至启动不起来
所以
在一个由@Configuration注解的配置类中通过@Autowired的方式注入一个SQL mapper类,需要在配置类或配置类的依赖中使用@MapperScan指定Mapper类所在包。
package com.fri.device.mapper;
import com.fri.device_authentication.entity.DeviceCertificationRecord;
import tk.mybatis.mapper.common.Mapper;
public interface DeviceMapper extends Mapper<Device> {
}
@Configuration
@MapperScan({"com.fri.device.mapper"})
public class DataReceiveConfigration {
@Autowired
private DeviceCertificationRecordMapper deviceCertificationRecordMapper;
//可以使用mapper
.....
}