栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

springboot+mybatis+mysql

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springboot+mybatis+mysql

首先导入springboot项目
项目结构图如下

1.下载依赖,在pom.xml文件添加如下代码

        
            mysql
            mysql-connector-java
            8.0.11
        
        
            org.mybatis
            mybatis
            3.4.4
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.1.1
        

接下来便是application.yml文件内容的修改,代码如下,数据库的连接自己修改

server:
  port: 8080

spring:
  datasource:
    driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/shangchen?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
    username: root
    password: root


mybatis:
  mapper-locations: classpath:mybatis/*Mapper.xml

在mybatis文件夹内填写Mapper.xml,本文案例如下




    
		select `gid`,`gname`,`gprice`,`gdesc` from Goods where gid = #{value}