微服务搭建之数据库相关

2018-01-17  本文已影响4人  天神Deity

1.MySQL数据源配置

在application.yml文件中加入MySQL数据源配置

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8
    driver-class-name: com.mysql.jdbc.Driver
    username: root
    password: password

2.加入数据库相关依赖包

1.使用MySQL驱动,在pom.xml中加入MySQL的依赖

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>

2.使用MyBatis,在pom.xml中加入MyBatis的依赖

<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>RELEASE</version>
</dependency>
上一篇 下一篇

猜你喜欢

热点阅读