亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Gradle 項目 --Failed to configure a DataSource'url'

Gradle 項目 --Failed to configure a DataSource'url'

呼喚遠方 2021-11-11 14:11:12
試圖按照https://spring.io/guides/gs/accessing-data-mysql/ 中的指南進行操作,但是當我啟動我的 java 應用程序時,它顯示以下錯誤:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.Reason: Failed to determine a suitable driver classAction:Consider the following:    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).這是我的 application.property:spring.jpa.hibernate.ddl-auto=createspring.datasource.url=jdbc:mysql://localhost:3306/db_currencyspring.datasource.username=springuserspring.datasource.password=ThePassword數據庫創建遵循以下指南:mysql> create database db_example; -- Create the new databasemysql> create user 'springuser'@'localhost' identified by 'ThePassword'; mysql> grant all on db_example.* to 'springuser'@'localhost';我的 build.gradle 是:buildscript {    repositories {        mavenCentral()    }    dependencies {        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")    }}apply plugin: 'java'apply plugin: 'eclipse'apply plugin: 'idea'apply plugin: 'org.springframework.boot'apply plugin: 'io.spring.dependency-management'bootJar {    baseName = 'gs-accessing-data-mysql'    version =  '0.1.0'}repositories {    mavenCentral()}sourceCompatibility = 1.8targetCompatibility = 1.8dependencies {    compile("org.springframework.boot:spring-boot-starter-web")    // JPA Data (We are going to use Repositories, Entities, Hibernate, etc...)    compile 'org.springframework.boot:spring-boot-starter-data-jpa'    // Use MySQL Connector-J    compile 'mysql:mysql-connector-java'    testCompile('org.springframework.boot:spring-boot-starter-test')}
查看完整描述

1 回答

?
開心每一天1111

TA貢獻1836條經驗 獲得超13個贊

通過研究,這個問題有多種答案適用于其他人,在我的情況下,將其添加到 application.properties 文件有效:

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL94Dialect


查看完整回答
反對 回復 2021-11-11
  • 1 回答
  • 0 關注
  • 318 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號