美文网首页
SpringBoot 整合Mysql

SpringBoot 整合Mysql

作者: code_搬运工 | 来源:发表于2022-07-11 13:26 被阅读0次

    pom.xml

    <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.29</version>
                <scope>runtime</scope>
    </dependency>
    <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid-spring-boot-starter</artifactId>
                <version>${druid.version}</version>
    </dependency>
    
    
    

    application.yml

    spring:
      datasource:
        url: jdbc:mysql://localhost:3306/demo?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
        username: root
        password: root
        driver-class-name: com.mysql.cj.jdbc.Driver
        type: com.alibaba.druid.pool.DruidDataSource
      druid:
        filters: stat,log4j2
        initial-size: 1
        min-idle: 1
        max-active: 20
        max-wait: 60000
        time-between-eviction-runs-millis: 60000
        min-evictable-idle-time-millis: 300000
        validation-query: SELECT 1
        test-while-idle: true
        test-on-borrow: false
        test-on-return: false
        query-timeout: 30
      servlet:
        multipart:
          enabled: true
          max-file-size: 5MB
          max-request-size: 10MB
    

    相关文章

      网友评论

          本文标题:SpringBoot 整合Mysql

          本文链接:https://www.haomeiwen.com/subject/eraobrtx.html