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

标签 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')
}

最佳答案

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

关于java - Gradle-无法确定合适的驱动程序类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53970955/

相关文章:

java - 使用setter方法创建Spring bean - 空指针异常

java - 自 12 :00 am December 31, 1989 Java 以来的秒数

java - Spring - 从对象池请求作用域 bean

JavaScript : Jump to method definition using eclipse

java - 如何在开发环境中使用自定义 JSP 标签

java - S/Mime 附件 java

java - 覆盖接口(interface)的变量?

java - 尽管无状态 session 管理,Spring 还是添加了一个 JSESSIONID

java - java spring中的注释@Repository如何工作?

java - 从 eclipse-jee-helios 创建 RCP 项目时遇到问题