gpt4 book ai didi

spring - 无法在 HikariConfig 类加载器或线程上下文中加载驱动程序类 oracle.jdbc.OracleDriver

转载 作者:行者123 更新时间:2023-12-04 04:09:11 24 4
gpt4 key购买 nike

我第一次使用 Spring 并尝试对其进行设置,以便我的代码可以访问 Oracle 数据库。我的 application.properties 中有以下配置:

spring.datasource.url=jdbc:oracle:thin:@140.192.30.237:1521:def
spring.datasource.username=<username>
spring.datasource.password=<password>
spring.datasource.driver.class-name=oracle.jdbc.driver.OracleDriver

我的 pom.xml 包含以下依赖项:
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

但是我收到以下错误并且不知道如何解决它,我从搜索中找到了类似的错误,但没有一个解决了我的问题:
Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:

Property: driverclassname
Value: oracle.jdbc.OracleDriver
Origin: "driverClassName" from property source "source"
Reason: Failed to load driver class oracle.jdbc.OracleDriver in either of HikariConfig class loader or Thread context classloader

Action:

Update your application's configuration

感谢您提供解决此问题的任何提示。

最佳答案

正如您在错误中提到的,问题出在您的配置上。
以下线路,

spring.datasource.driver.class-name=oracle.jdbc.driver.OracleDriver

应该改变为,
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver

Note that its not driver.class-name, instead its driver-class-name

关于spring - 无法在 HikariConfig 类加载器或线程上下文中加载驱动程序类 oracle.jdbc.OracleDriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52470736/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com