Spring Boot 集成 MyBatis + Druid 快速开发
Spring Boot 简介
Spring Boot 是由 Pivotal 团队提供的全新框架,其设计目的是用来简化新 Spring 应用的初始搭建以及开发过程。
该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。
通过这种方式,Spring Boot 致力于在蓬勃发展的快速应用开发领域(rapidapplication development)成为领导者。
集成SpringBoot + MyBatis + Druid 开发环境
项目依赖
SpringBoot的Maven依赖如下,这里我选择的SpringBoot版本为当前最新版 2.1.3
<!-- 集成Thymeleaf模板引擎 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- Web场景启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- MyBatis 启动器 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<!-- 开发者工具 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- SpringBoot 的测试依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 德鲁伊连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>

本文介绍了如何在Spring Boot 2.1.3项目中集成MyBatis和Druid连接池。首先,文章简述了Spring Boot的基本概念,然后详细说明了集成过程,包括设置项目依赖、配置文件,特别是Druid的集成步骤。最后,文章提供了测试集成结果的代码示例,包括实体类、Mapper接口、Service层及ServiceImpl实现,确保集成正常运行。

4491

被折叠的 条评论
为什么被折叠?



