SpringBoot mysql数据库配置

 

 

记录下SpringBoot数据库配置,方便创项目后直接cv ,免得以后打错

 

<!-- MySQL驱动依赖 -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>

    <!-- Spring Data JPA依赖 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

 

#项目服务器端口
server:
  port: 8080

spring:
#  数据库配置
  datasource:
    username: 这里输入mysql用户名
    password: 这里输入mysql密码
    url: jdbc:mysql://localhost:3306/这里填连哪个数据库名?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=UTF-8
    driver-class-name: com.mysql.jdbc.Driver
    
#   下面的内容是额外配置,如果不需要直接删除就行 不用配
#   换阿里的druid连接池
    type: com.alibaba.druid.pool.DruidDataSource  
#    配置druid
    druid:
      max-active: 20
      initial-size: 5
      min-idle: 10
      max-wait: 60000

 

本文作者:Hello

本文链接:https://www.cnblogs.com/Hello233/p/16258018.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Hello霖  阅读(2023)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起