SpringBoot文件映射配置 SpringBoot使用Mybatis&Mybatis-plus文件映射配置方法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

SpringBoot文件映射配置 SpringBoot使用Mybatis&Mybatis-plus文件映射配置方法

涛姐涛哥   2021-05-06 我要评论
想了解SpringBoot使用Mybatis&Mybatis-plus文件映射配置方法的相关内容吗,涛姐涛哥在本文为您仔细讲解SpringBoot文件映射配置的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:SpringBoot文件映射配置,SpringBoot文件映射,下面大家一起来学习吧。

简介:

Springboot使用Mybatis&Mybatis-plus 两者文件映射配置略有不同,之前我用的是Mybatis,但公司用Mybatis-plus;自己新建了一个Springboot项目,代码运行时一直报错not found not found,明明配置了mybatis相关信息的扫描路径,但是就是not found;检查修改了很多地方但都是无用功,最终发现是Plus惹的祸。

1、使用Mybatis

<dependency>
   <groupId>org.mybatis.spring.boot</groupId>
   <artifactId>mybatis-spring-boot-starter</artifactId>
   <version>1.3.2</version>
</dependency>

yml文件配置的mapper映射及相关信息格式:

mybatis:
  mapper-locations: classpath:mybatis/mapper/*.xml
  config-locations: classpath:mybatis/mybatis-config.xml
  type-aliases-package: com.ausclouds.bdbsec.entity

2、使用Mybatis-Plus

 <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.2.0</version>
 </dependency>

yml文件配置的mapper映射及相关信息格式:

mybatis-plus:
  mapper-locations: classpath:mybatis/mapper/*.xml
  config-locations: classpath:mybatis/mybatis-config.xml
  type-aliases-package: com.example.demo.entity

3、Others

加上@Slf4j 注解后,仍然不能用log直接支配日志,因为没有安装Lombok插件。

加上@Data 注解后,仍然不能使用getter/setter,因为没有安装Lombok插件。

在类上加注解@AllArgsConstructor 注解可以代替所有@Autowired 注解,就不用在一个类中引入多个@Autowired。
下载前端代码后需要在控制台运行:npm install,下载前端工程后在控制台npm install 相当于后端的下载jar包,目录级别还不能乱放,按照git工程代码格式,不能新建目录文件,否则资源下不来。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们