gpt4 book ai didi

oracle - Spring boot无法加载驱动程序类: oracle. jdbc.OracleDrive

转载 作者:行者123 更新时间:2023-12-01 23:33:10 24 4
gpt4 key购买 nike

我的 jar 中的类路径中有驱动程序类:

2015-06-18 12:21:40.290 INFO 9453 --- [ main] .b.l.ClasspathLoggingApplicationListener :应用程序无法使用类路径启动:……jar:文件:/{projecthome}/rest-test/target/rest-test-0.1.0.jar!/lib/ojdbc6-11.2.0.3.0.jar!/]

我遇到异常:

Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.OracleDrive

我的pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.springframework</groupId>
<artifactId>rest-test</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>

<properties>
<start-class>hello.Application</start-class>
<java.version>1.8</java.version>
</properties>


<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.4.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-dbcp</artifactId>
<version>${tomcat.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
<name>rest-test</name>
</project>

最佳答案

从 Oracle 网站下载 ojdbc6.jar,或者如果您在本地系统中安装了 oracle11g,则可以在 jdbc/lib 文件夹中找到 ojdbc。

添加 ojdbc.jar 右键 -> 构建路径 -> 配置构建路径 -> 添加外部 jars -> 你的本地机器 ojdbc 路径 -> 确定。

它对我的情况有效。

关于oracle - Spring boot无法加载驱动程序类: oracle. jdbc.OracleDrive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30913841/

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