美文网首页Java 杂谈
一,Spring Boot基于MYSQL,MyBatis配置(G

一,Spring Boot基于MYSQL,MyBatis配置(G

作者: Wocus | 来源:发表于2018-09-25 14:57 被阅读0次
使用IDEA创建Spring Boot项目

1.新建项目就不多说了,只做简述
①File->New-Project
②选择Spring Initializr 勾选Default Next
③根据自己的需求选择相应的选项,我这里选择Type:Gradle,Language:Kotlin其他的默认 Next
④勾选Web,MySQL,MyBatis,Freemarker Next
⑤Finish

项目新建完成,目前启动会报错,需要配置下mysql,我这里使用的是Druid,需要导入这个包

application.yml文件配置

spring:
    datasource:
        name: test
        url: jdbc:mysql://localhost:3306/wocus
        username: root
        password: 123456
        # 使用druid数据源
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        filters: stat
        maxActive: 20
        initialSize: 1
        maxWait: 60000
        minIdle: 1
        timeBetweenEvictionRunsMillis: 60000
        minEvictableIdleTimeMillis: 300000
        validationQuery: select 'x'
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        poolPreparedStatements: true
        maxOpenPreparedStatements: 20

Gradle配置加入以下jar包

compile('com.alibaba:druid-spring-boot-starter:1.1.0')

启动项目,无误

相关文章

网友评论

    本文标题:一,Spring Boot基于MYSQL,MyBatis配置(G

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