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
  • 相关阅读:
    系统调用简单总结
    系统调用原理详解
    总结:c 语言与Linux操作系统的关系
    poj3171 Cleaning Shifts
    洛谷P1032 字串变换
    poj3662 Telephone Lines
    洛谷P1073 最优贸易
    Uva1330/poj1964 City Game
    poj2559/SP1805 Largest Rectangle in a Histogram
    洛谷 P1196 [NOI2002]银河英雄传说
  • 原文地址:https://www.cnblogs.com/gjq1126-web/p/12566127.html
Copyright © 2011-2022 走看看