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

Spring Boot项目无法连接PostgreSQL数据库启动报错问题咨询

解决步骤

  • 强制更新Maven依赖:在Eclipse中右键项目,选择Maven -> Update Project,勾选Force Update of Snapshots/Releases,更新完成后重启项目。这是Eclipse环境下最常见的Maven依赖缓存异常导致驱动未加载的解决方案。
  • 显式配置数据库驱动类:在application.properties中添加如下配置,避免Spring Boot自动推断驱动类失效:
spring.datasource.driver-class-name=org.postgresql.Driver
  • 适配PostgreSQL版本:若本地PostgreSQL数据库版本≥13,可在pom.xml的PostgreSQL依赖中显式指定高版本驱动,覆盖Spring Boot父依赖默认的版本:
<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.6.0</version>
    <scope>runtime</scope>
</dependency>
  • 清理项目缓存:点击Eclipse顶部菜单栏Project -> Clean,选中当前项目清理构建产物,重新编译后启动。

内容的提问来源于stack exchange,提问作者Murillo Jorge Nobrega de Melo

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 12:36:05