无法创建池的初始连接-Spring Boot与Oracle DB



我正在尝试使用Oracle数据库运行Springboot应用程序。执行后

java -jar SpringBootHibernate-0.0.1-SNAPSHOT.jar

获取以下错误无法创建池的初始连接

2020-09-26 13:35:24 INFO  com.programmer.gate.Application - Starting Application v0.0.1-SNAPSHOT on lax13 with PID 1356 (/home/cavisson/spring-boot-jpa-hibernate-master/target/SpringBootHibernate-0.0.1-SNAPSHOT.jar started by root in /home/cavisson/spring-boot-jpa-hibernate-master/target)
2020-09-26 13:35:24 INFO  com.programmer.gate.Application - No active profile set, falling back to default profiles: default
2020-09-26 13:35:24 INFO  o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@443b7951: startup date [Sat Sep 26 13:35:24 IST 2020]; root of context hierarchy
2020-09-26 13:35:25 WARN  o.a.tomcat.jdbc.pool.ConnectionPool - initialSize is larger than maxActive, setting initialSize to: 1
2020-09-26 13:35:25 WARN  o.a.tomcat.jdbc.pool.ConnectionPool - minIdle is larger than maxActive, setting minIdle to: 1
2020-09-26 13:35:25 WARN  o.a.tomcat.jdbc.pool.ConnectionPool - maxIdle is larger than maxActive, setting maxIdle to: 1
2020-09-26 13:35:25 ERROR o.a.tomcat.jdbc.pool.ConnectionPool - Unable to create initial connections of pool.
java.sql.SQLException: Unable to load class: oracle.jdbc.OracleDriver from ClassLoader:org.springframework.boot.loader.LaunchedURLClassLoader@19469ea2;ClassLoader:org.springframework.boot.loader.LaunchedURLClassLoader@19469ea2

有人能帮我解释这个错误背后的原因吗?|我已经交叉检查了oracle连接是否正常。

这是我的应用程序属性-

# create n drop tables, loads import.sql
spring.jpa.hibernate.ddl-auto=create-drop
# Oracle settings
spring.datasource.url=jdbc:oracle:thin:@HostIP:1521:orcl
spring.datasource.username=SYS
spring.datasource.password=ABC@123
spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver
# logging
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.level.org.hibernate.SQL=debug
spring.datasource.dbcp2.max-total=1
spring.datasource.tomcat.max-active=1

POM.xml 中的条目

<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
</dependency>

从您共享的日志来看,您的pom.xml中似乎缺少Oracle Driver

转到pom.xml,滚动至<dependencies>部分,然后添加以下依赖

<!-- https://mvnrepository.com/artifact/com.oracle.jdbc/ojdbc8 -->
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>

然后进行maven clean安装以创建一个新的jar,并确保您不仅复制粘贴此处提供的oracle依赖项,还检查它是否与您的oracle版本相对应。

请编辑您的问题并添加pom.xml以及的详细信息

相关内容

最新更新