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

Wildfly 24连接PostgreSQL提示No suitable driver found如何解决?

排查修复步骤

  • 首先确认PostgreSQL驱动模块配置正确性
    • 驱动模块必须放在Wildfly根目录下的modules/org/postgresql/main/路径中,该目录下必须同时存在postgresql-42.2.24.jar和module.xml两个文件
    • 核对module.xml内容,确保没有拼写错误,参考正确配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
    <resources>
        <resource-root path="postgresql-42.2.24.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>
  • 确认你使用的postgresql-42.2.24.jar是官方二进制包,不是源码包,解压后可在org/postgresql/路径下找到Driver.class文件,排除包损坏的问题
  • 核对服务器配置文件(使用standalone模式则为standalone/configuration/standalone.xml,domain模式则对应domain配置文件)里的数据源和驱动注册配置
    • 驱动注册部分必须明确指定驱动类,参考配置:
<subsystem xmlns="urn:jboss:domain:datasources:6.0">
    <datasources>
        <drivers>
            <driver name="postgresql" module="org.postgresql">
                <driver-class>org.postgresql.Driver</driver-class>
                <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
            </driver>
        </drivers>
    </datasources>
</subsystem>
  • 修正你的JDBC URL为规范小写格式:jdbc:postgresql://localhost:5432/postgres,避免大小写导致的识别异常
  • 排查应用包冲突:检查你部署到Wildfly的war/ear包是否自带了PostgreSQL驱动,如果有,将项目中PostgreSQL依赖的scope改为provided,打包时排除该依赖,避免和Wildfly全局模块的驱动产生类加载冲突
  • 清理缓存重启服务:停掉Wildfly服务后,删除standalone/tmp和standalone/data目录下的所有缓存文件,再重新启动服务,在管理控制台的数据源测试页面直接测试连接,确认配置生效

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.29 20:45:03