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
  • 相关阅读:
    hdu 1142 用优先队列实现Dijkstra
    POJ 2063 Investment 完全背包
    POJ 3260 多重背包+完全背包
    bignum 大数模板
    POJ 3468(树状数组的威力)
    POJ 3468 线段树裸题
    hdu 1058 Humble Numbers
    CodeForces 185A 快速幂
    POJ 1990 MooFest 树状数组
    设计模式(20)策略模式
  • 原文地址:https://www.cnblogs.com/gjq1126-web/p/12566127.html
Copyright © 2011-2022 走看看