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

Spring Boot JDBC启动异常求助:跟随官方教程实践遇问题

Hey, let's walk through the most common pitfalls that cause startup exceptions when setting up Spring Boot with Oracle JDBC—since you mentioned you've worked through the official tutorial, set up your Eclipse project, added JDBC dependencies, handled the ojdbc14 jar, and configured application.properties but hit a snag.

排查Spring Boot + Oracle JDBC启动异常的核心方向

First off, grab the core exception details—the Caused by section in your console stack trace is the real clue here. It’ll tell you if it’s a class loading issue, connection failure, or syntax error. With that in mind, here are the top issues to check:

1. ojdbc14 Compatibility Mismatch

ojdbc14 is a legacy driver built for JDK 1.4, but modern Spring Boot versions (2.x+, 3.x) rely on JDK 8 or newer. This version mismatch almost always causes class loading failures or connection errors.

  • Fix: Swap to a driver matching your JDK: use ojdbc8 for JDK 8, ojdbc11 for JDK 17, etc.
  • If you must use ojdbc14: Ensure you’re on a very old Spring Boot version (1.x) and that the jar is properly installed to your local Maven repo. Run this command to install it (adjust the version and file path to match your jar):
    mvn install:install-file -Dfile=ojdbc14.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar
    
    Double-check that your pom.xml dependency matches the groupId, artifactId, and version you used in the command.

2. Incorrect application.properties Config

Oracle’s connection settings are easy to mix up with other databases. Verify these key entries:

  • URL Format (SID mode): spring.datasource.url=jdbc:oracle:thin:@localhost:1521:ORCL
  • URL Format (service name mode, common for newer Oracle versions): spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/ORCLPDB1
  • Credentials: Make sure spring.datasource.username and spring.datasource.password match your Oracle user’s details.
  • Driver Class: For ojdbc14, use spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver (newer drivers use oracle.jdbc.OracleDriver).

3. Eclipse Maven Dependency Sync Issues

Sometimes Eclipse doesn’t pick up manual jar installs or pom changes automatically:

  • Right-click your project → Maven → Update Project, then check "Force Update of Snapshots/Releases".
  • Verify the ojdbc14.jar appears under your project’s Maven Dependencies folder. If not, your local repo install step failed.

4. Oracle Service Not Running

If your error is a connection timeout or "connection refused", check if Oracle’s services are up:

  • Run lsnrctl status in your terminal to confirm the listener is running.
  • Open your system’s service manager (Windows Services, Linux systemd) to ensure the Oracle database instance service is active.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:02:27