Gradle-无法确定合适的驱动程序类别

时间:2018-12-29 15:44:33

标签: java spring eclipse spring-boot gradle

我是Spring-boot的新手,我想使用Eclipse,Spring和Gradle创建应用程序。创建“ Spring Starter Project”后,我无法运行该应用程序。跟踪显示:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-30 19:26:36.732 ERROR 3483 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

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).

这是我的“ build.gradle”文件:

buildscript {
    ext {
        springBootVersion = '2.1.1.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    implementation('org.springframework.boot:spring-boot-starter-actuator')
    implementation('org.springframework.boot:spring-boot-starter-data-jpa')
    implementation('org.springframework.boot:spring-boot-starter-web')
    testImplementation('org.springframework.boot:spring-boot-starter-test')
}

2 个答案:

答案 0 :(得分:0)

在gradle依赖项中添加实现('com.h2database.h2')。 默认情况下,spring boot自动使用此数据库URL“ jdbc:h2:mem:testdb”配置h2

答案 1 :(得分:0)

在我的情况下,文件application.properties位于src/main/resources/static中,将其移至src/main/resources已解决该错误