zoukankan      html  css  js  c++  java
  • SpringBoot 中MyBatis的配置

    经实践,分享两种配置方法:

    方法一:使用类中加注解@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
  • 相关阅读:
    第五周反向传播算法
    PHP数组排序
    <meta-data>
    Android之Intent
    Fragment生命周期
    前端后台学习笔记汇杂
    IntelliJ IDEA 14.x 与 Tomcat 集成,创建并运行Java Web项目
    用java将excel中数据导入mysql
    幸运观众抽奖
    JTextField
  • 原文地址:https://www.cnblogs.com/gjq1126-web/p/12566127.html
Copyright © 2011-2022 走看看