经实践,分享两种配置方法:
方法一:使用类中加注解@Mapper
import com.gjq.admin.demo.domain.pri.SysMenu;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface SysMenuMapper {
int deleteByPrimaryKey(Long menuId);
int insert(SysMenu record);
int insertSelective(SysMenu record);
SysMenu selectByPrimaryKey(Long menuId);
int updateByPrimaryKeySelective(SysMenu record);
int updateByPrimaryKey(SysMenu record);
}
然后在配置文件中配置xml路径,我的XML是放在resources=>mapper下面
在application.yml中配置 如下:
mybatis :
mapper-locations : classpath:mapper/pri/*.xml
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
方法二:在启动类使用:@MapperScan
@SpringBootApplication
@MapperScan("com.gjq.admin.demo.mapper.pri")
public class AdminDemoApplication {
public static void main(String[] args) {
SpringApplication.run(AdminDemoApplication.class, args);
}
}
在application.yml中配置 如下:
mybatis :
mapper-locations : classpath:mapper/pri/*.xml