Springboot配置application.yml连接MySQL数据库

1.在pom.xml的标签中中加入以下依赖

org.springframework.boot
spring-boot-starter-web

   
         org.mybatis.spring.boot
        mybatis-spring-boot-starter
         2.0.1
    

    
        mysql
       mysql-connector-java
       runtime
    

    
        com.alibaba
       druid
         1.1.10
   

把resource包下的application.properties复制一份再粘贴名字改成application.yml,加入以下内容
server:
port: 8080
servlet:
context-path: /
spring:
datasource:
username: root
password:
url: jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver

你可能感兴趣的:(Springboot配置application.yml连接MySQL数据库)