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

SpringBoot4+MyBatis+Oracle10g项目Ojdbc6 Class Not Found问题求助

Fixing ojdbc6 Class Not Found Error in Spring Boot + MyBatis + Oracle 10g Setup

I've run into this exact issue a few times with Oracle JDBC drivers and Maven, so let's break down the troubleshooting steps to get this sorted:

  • Verify Local Maven Repository Installation
    First, double-check that the ojdbc6 jar was actually installed correctly in your local Maven repo. Navigate to ~/.m2/repository/com/oracle/ojdbc6/11.2.0.4/ (on Windows it's C:\Users\<your-user>\.m2\repository\com\oracle\ojdbc6\11.2.0.4\). You should see three files here: ojdbc6.jar, ojdbc6.pom, and _remote.repositories. If any of these are missing, re-run your install command with admin/root privileges (sometimes file permissions prevent Maven from writing to the repo):

    mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dpackaging=jar -Dversion=11.2.0.4 -Dfile=ojdbc6.jar -DgeneratePom=true
    
  • Check pom.xml Dependency Configuration
    Make sure your dependency entry exactly matches the install parameters, and watch out for hidden issues:

    • No typos in groupId, artifactId, or version (they must match com.oracle, ojdbc6, 11.2.0.4 respectively)
    • Remove any incorrect <scope> tags like <scope>provided</scope> — if you set this, Maven won't include the jar in your runtime classpath, which directly causes the Class Not Found error
      Your dependency should look like this:
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.4</version>
    </dependency>
    
  • Spring Boot Version Compatibility Check
    Wait, you mentioned "SpringBoot4" — that's likely a typo (Spring Boot's latest stable as of now is 3.x). If you're using Spring Boot 3.x, it requires Java 17+, but ojdbc6 is built for Java 6. This version mismatch can cause class loading failures. Since Oracle 10g is end-of-life and won't support newer JDBC drivers, your best bet is to downgrade Spring Boot to 2.x (which supports Java 8, fully compatible with ojdbc6).

  • Refresh Maven and Clear Caches
    Maven sometimes caches stale dependency data. Run these commands to clean and refresh your project:

    mvn clean install -U
    

    The -U flag forces Maven to update dependencies and ignore cached versions, ensuring it picks up your locally installed ojdbc6.

  • Fix IDE Sync Issues
    If you're using an IDE like IntelliJ IDEA or Eclipse, it might not have picked up the new dependency yet:

    • In IntelliJ: Right-click your project → Maven → Reimport All Maven Projects. You can also go to File → Invalidate Caches... → Invalidate and Restart to clear any stuck cache.
    • In Eclipse: Right-click your project → Maven → Update Project. Make sure "Force Update of Snapshots/Releases" is checked before clicking OK.
  • Verify Driver Class and DataSource Configuration
    Ensure your Spring Boot application.properties/application.yml has the correct driver class for ojdbc6:

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

    This class is present in ojdbc6.jar, so if the jar is properly in your classpath, this should resolve correctly.

  • Try a More Compatible ojdbc6 Version for Oracle 10g
    The 11.2.0.4 ojdbc6 is targeted at Oracle 11g. For better compatibility with Oracle 10g, try installing the 10.2.0.5 version of ojdbc6 instead:

    mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dpackaging=jar -Dversion=10.2.0.5 -Dfile=ojdbc6.jar -DgeneratePom=true
    

    Then update your pom.xml dependency version to 10.2.0.5.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 09:59:44