简单创建SpringBoot+Mybatis项目

这篇博客详细介绍了如何使用Eclipse创建一个Maven项目,集成SpringBoot和Mybatis,包括配置pom.xml,设置数据库连接,创建User类、UserService、UserMapper,以及创建和运行启动类。同时,提到了UserMapper的两种创建方式:注解和XML配置文件。
摘要由CSDN通过智能技术生成

创建一个简单的SpringBoot+Mybatis

  • 开发工具及环境

    • Eclipse
    • JDK1.8
    • Maven
  • 开发过程

  1. 用Eclipse创建Maven项目
  2. 修改pom.xml文件
  3. 编写配置文件
  4. 编写业务代码
  5. 运行

用Eclipse创建Maven项目

  1. File-> New-> Project,搜索Maven,选择Maven Project。在这里插入图片描述
  2. 按如下选择,点Next。
    在这里插入图片描述
  3. 在下图中填写Group Id和Artifact Id,之后点击Finish。
    在这里插入图片描述

修改pom.xml文件

在SpringBoot+Mybatis中,需要将相关包导入


<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
 </dependency>
 <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test</artifactId>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-data-jpa</artifactId>
  </dependency>
  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
  </dependency>
  <dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
   <scope>runtime</scope>
  </dependency>
  <dependency>
   <groupId>org.mybatis.spring.boot</groupId>
   <artifactId>mybatis-spring-boot-starter</artifactId>
   <version>1.2.2</version>
  </dependency>
  <dependency>
   <groupId>com.github.pagehelper</groupId>
   <artifactId>pagehelper-spring-boot-starter</artifactId>
   <version>1.2.3</version>
  </dependency>
  <dependency>
   <groupId>tk.mybatis</groupId>
   <artifactId>mapper-spring-boot-starter</artifactId>
   <version>2.0.2</version>
  </dependency>
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值