【问题标题】:Reason: Failed to determine a suitable driver class原因:无法确定合适的驱动程序类
【发布时间】:2022-01-19 18:23:31
【问题描述】:
    spring:
  application:
    name: businessassistant-opendata
  jmx:
    enabled: true
h2:
       console:
       enabled: true
       path: /h2-console
    
datasource:
      url: jdbc:h2:file:~/test
      driverClassName: org.h2.Driver
      username: sa
      password:
      database-platform: org.hibernate.dialect.H2Dialect

server:
  port: 8762

嗨。我尝试启动我的 Gradle 项目,但我的属性配置有问题。我试图了解会发生什么,但我找不到解决方案。感谢您的宝贵时间。

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter-web:2.6.1'
    implementation 'org.springframework.boot:spring-boot-starter-webflux:2.6.1'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.6.1'
    implementation group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '2.6.1'
    implementation 'io.springfox:springfox-boot-starter:3.0.0'
    implementation 'io.springfox:springfox-swagger-ui:3.0.0'
    implementation 'org.json:json:20210307'
    implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.6.0'
    implementation group: 'org.springframework', name: 'spring-context', version: '5.3.13'
    implementation group: 'org.springframework', name: 'spring-orm', version: '5.3.13'

    // JAX-B dependencies for JDK 9+
    implementation 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2'
    implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.2'
    

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
    testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.6.1'
    testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.2'
    testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.1.0'
    testImplementation group: 'org.springframework', name: 'spring-test', version: '5.3.13'
    implementation group: 'com.h2database', name: 'h2', version: '2.0.202'
    testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.6.1'

Thaqt 是 build.gradle 文件。

【问题讨论】:

  • 也许添加您的 build.gradle 文件(在您应用我的解决方案之前),以便其他人可以更好地理解您的问题。
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: spring spring-boot gradle h2


【解决方案1】:

你需要将h2的驱动添加到你的依赖中:

build.gradle:

//...

dependencies {
  //...
  implementation 'com.h2database:h2:2.0.202'
}

【讨论】:

  • 你好。 Ya estaban añadidas。
  • 如果您认为答案正确,您可以点赞。
猜你喜欢
  • 2021-01-24
  • 2019-03-18
  • 2019-05-27
  • 2021-11-22
  • 2021-09-12
  • 2023-02-04
  • 2019-12-06
  • 2019-05-10
  • 2010-09-14
相关资源
最近更新 更多