美文网首页
微服务搭建之数据库相关

微服务搭建之数据库相关

作者: 天神Deity | 来源:发表于2018-01-17 23:34 被阅读4次

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>

相关文章

网友评论

      本文标题:微服务搭建之数据库相关

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