iis服务器助手广告广告
返回顶部
首页 > 资讯 > 精选 >详解SpringBoot 快速整合MyBatis(去XML化)
  • 870
分享到

详解SpringBoot 快速整合MyBatis(去XML化)

springbootmybatis 2023-05-31 00:05:27 870人浏览 薄情痞子
摘要

序言:此前,我们主要通过XML来书写sql和填补对象映射关系。在SpringBoot中我们可以通过注解来快速编写SQL并实现数据访问。(仅需配置:mybatis.configuration.map-underscore-to-camel-c

序言:

此前,我们主要通过XML来书写sql和填补对象映射关系。在SpringBoot中我们可以通过注解来快速编写SQL并实现数据访问。(仅需配置:mybatis.configuration.map-underscore-to-camel-case=true)。为了方便大家,本案例提供较完整的层次逻辑springBoot+MyBatis+Annotation。

具体步骤

1. 引入依赖

在pom.xml 引入ORM框架(Mybaits-Starter)和数据库驱动(MySQL-Conn)的依赖。

<?xml version="1.0" encoding="UTF-8"?><project xmlns="Http://Maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  <!--继承信息 -->  <parent>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-parent</artifactId>    <version>2.0.0.M4</version>    <relativePath/>  </parent>  <!--依赖管理 -->  <dependencies>    <dependency> <!--添加WEB依赖 -->      <groupId>org.springframework.boot</groupId>      <artifactId>spring-boot-starter-web</artifactId>    </dependency>    <dependency> <!--添加Mybatis依赖 -->      <groupId>org.mybatis.spring.boot</groupId>      <artifactId>mybatis-spring-boot-starter</artifactId>      <version>1.3.1</version>    </dependency>    <dependency><!--添加Mysql驱动依赖 -->      <groupId>mysql</groupId>      <artifactId>mysql-connector-java</artifactId>      <scope>runtime</scope>    </dependency>    <dependency><!--添加Test依赖 -->      <groupId>org.springframework.boot</groupId>      <artifactId>spring-boot-starter-test</artifactId>      <scope>test</scope>    </dependency>  </dependencies></project>

--结束END--

本文标题: 详解SpringBoot 快速整合MyBatis(去XML化)

本文链接: https://www.lsjlt.com/news/222672.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作