springboot第十二天

springboot1.0,2014年发布,默认数据库连接池为 Tomcat JDBC Pool
springboot2.0,2018年3月1日发布,默认数据库连接池为  Hikari


1.项目创建选择组件:mysql,jdbc    web

application.yml里:

spring:
datasource:
username: root
password: root
#使用 MySQL连接驱动是8.0以上,需要在Url后面加上时区, GMT%2B8代表中国时区,不然报时区
错误
url: jdbc:mysql://127.0.0.1:3306/jdbc?serverTimezone=GMT%2B8
# 注意: 新版本驱动包,要使用以下类作为驱动类
driver-class-name: com.mysql.cj.jdbc.Driver


@RestController注解=@Controller+@ResponseBody

druid

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.12</version>
</dependency>

mybatis
创建项目    选择mybatis,jdbc,mysql   web


@MapperScan("com.mengxuegu.springboot.mapper")会自动装配指定包下面所有Mapper,省得在
每个Mapper上面写@Mapper

Mybatis官网: http://www.mybatis.org/mybatis-3/zh/index.html
mybatis通常用xml方式,小项目才用注解方式

在 resources 创建以下目录和核心配置文件mybatis-config.xml与mapper映射文件夹
mapper下一般装xxmapper.xml

mybatis-config.xml里加上驼峰映射
<configuration>
    <!--核心配置文件-->
    <settings>
        <setting name="mapUnderscoreToCamelCase" value="true"/>
    </settings>
</configuration>


application.yml里

#配置mybatis相关文件路径
mybatis:
  #映射配置文件路径
  mapper-locations: classpath:mybatis/mapper/*.xml
  #核心配置文件路径
  config-location: classpath:mybatis/mybatis-config.xml

IOexception
servletexception
SQLException
InterruptedException
MessagingException
UnknownHostException
RuntimeException

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值