Linux 拨号vps windows公众号手机端

springboot数据源怎么配置

lewis 8年前 (2017-08-13) 阅读数 12 #程序编程
文章标签 springboot

在Spring Boot中,可以通过application.properties或application.yml文件来配置数据源。以下是两个示例:
1. application.properties配置文件示例:

#数据源配置
spring.datasource.url=jdbc:mysql://localhost:3306/demo
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

2. application.yml配置文件示例:

#数据源配置
spring:

  datasource:

    url: jdbc:mysql://localhost:3306/demo

    username: root

    password: 123456

    driver-class-name: com.mysql.jdbc.Driver

以上示例中,配置了一个名为"demo"的MySQL数据源,其中包括URL、用户名、密码和驱动类。根据实际情况,你需要将这些配置修改为你自己的数据库信息。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门