SpringBoot项目数据库配置
程序员文章站
2022-07-12 23:51:51
...
SpringBoot项目数据库配置
application.properties
//demo是数据库名
spring.datasource.url=jdbc:mysql://localhost:3306/demo?serverTimezone=UTC&characterEncoding=utf-8 //demo
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
//配置mybatis,引用实体类时可以使用实体类的别名来代替实体类,达到简写的目的,demo1是项目名
mybatis.type-aliases-package=gu.demo1.entity
application.yml
#数据库数据源
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
username: root
password: 123456
url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis:
type-aliases-package: com.gu.pojo #放置别名
mapper-locations: classpath:/mybatis/*.xml #放置xml文件
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl