You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring MVC环境下Maven依赖Oracle JDBC驱动找不到问题求助

Fixing Oracle JDBC Driver Not Found Issue with Spring Boot 2.0.0 & Maven

Hey there, let's work through this frustrating JDBC driver problem you're hitting. The root cause here is almost certainly that Oracle's JDBC drivers aren't hosted in the public Maven Central Repository—Oracle restricts distribution of these jars, so plain pom.xml dependencies won't download automatically. Let's break down the fixes step by step:

1. Install the Oracle JDBC Driver to Your Local Maven Repository Properly

Just copying the jar into your ./m2 folder won't cut it—Maven needs metadata (like a pom.xml file) to recognize the dependency. Use the Maven install:install-file command to properly register the jar:

First, download the correct JDBC driver for your Oracle XE version:

  • Oracle XE 11g → use ojdbc6.jar (version ~11.2.0.4)
  • Oracle XE 18c/21c → use ojdbc8.jar (version ~12.2.0.1 or higher)

Then run this command in your terminal (replace the placeholders with your actual file path and version):

mvn install:install-file -Dfile=/path/to/your/ojdbc8.jar -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar

This will place the jar and auto-generate the necessary metadata in your local ./m2 repository.

2. Add the Correct Dependency to Your pom.xml

Once the driver is installed locally, add this dependency to your project's pom.xml (match the groupId, artifactId, and version to what you used in the install command):

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>12.2.0.1</version>
</dependency>

For Spring Boot, you can also optionally use the spring-boot-starter-jdbc or spring-boot-starter-data-jpa starters alongside this to simplify database setup.

3. Verify Your Spring Boot Database Configuration

Double-check your application.properties (or application.yml) for correct connection details:

# Oracle XE connection string
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:XE
# Correct driver class
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
# Your Oracle username/password
spring.datasource.username=your_db_username
spring.datasource.password=your_db_password

Make sure the port 1521 and service name XE match your Oracle XE setup—sometimes XE uses ORCL as the service name instead, so adjust if needed.

4. Fix STS Maven Repository Configuration

Ensure STS is pointing to your local ./m2 repository:

  1. Open STS and go to Window > Preferences > Maven > User Settings
  2. Confirm the User Settings path points to your settings.xml (usually in ~/.m2/settings.xml)
  3. Click Update Settings and then Reindex to refresh Maven's cache

5. Clean and Rebuild Your Project

Finally, clear any cached build artifacts and rebuild:

  • In STS: Right-click your project → Maven > Clean, then Maven > Install
  • Or via command line: mvn clean install

This should resolve the "driver not found" error by ensuring Maven properly recognizes and loads the Oracle JDBC driver.

内容的提问来源于stack exchange,提问作者Bshwajeet

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:22:09