springboot整合mybatis,操作MySQL数据库

idea 新建项目选中Spring initializr,如下图所示

 

 勾选这几个组件

 构建多环境部署文件,resources 文件夹下面创建一个application-dev.properties 文件

application.properties设置读取默认环境

spring.application.name=MybatisSpringbootIntegration
spring.profiles.active=dev

 application-dev.properties 配置文件

server.port=2333
spring.datasource.url=jdbc:mysql://127.0.0.1/test?serverTimezone=GMT%2B8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# Mybatis 实体类路径
mybatis.typeAliasesPackage=com.example.test.entity
# mybatis mapper文件加载路径
mybatis.mapperLocations=classpath:mapper/*.xml
# 数据库返回为null出来
mybatis.configuration.call-setters-on-nulls=true
# 是否开启驼峰转换
mybatis.configuration.map-underscore-to-camel-case=true
# 打印sql
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

resources 目录下创建mapper文件夹用于存放.xml文件

mapper文件dao层和实体类做下关联

启动文件新增扫描dao层路径标签

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值