Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 未找到maven依赖项的Postgresql驱动程序_Spring_Postgresql_Maven_Dependencies_Driver - Fatal编程技术网

Spring 未找到maven依赖项的Postgresql驱动程序

Spring 未找到maven依赖项的Postgresql驱动程序,spring,postgresql,maven,dependencies,driver,Spring,Postgresql,Maven,Dependencies,Driver,我正在与maven一起运行一个spring项目,并尝试使用postgresql。我已将依赖项添加到pom.xml中,但在tomcat启动时,出现以下错误: java.lang.ClassNotFoundException: org.postgresql.Driver pom.xml依赖项: <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</a

我正在与maven一起运行一个spring项目,并尝试使用postgresql。我已将依赖项添加到pom.xml中,但在tomcat启动时,出现以下错误:

java.lang.ClassNotFoundException: org.postgresql.Driver
pom.xml依赖项:

<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>9.3-1101-jdbc41</version>
</dependency>

org.postgresql
postgresql
9.3-1101-jdbc41

Maven似乎没有下载jar,因此找不到驱动程序类。有什么想法吗?

当我把这个放到我的pom中时,工件被下载了。也许您应该清理maven存储库缓存或手动删除文件夹,然后重试。

您需要将jar的副本放在tomcat/lib文件夹中

Maven没有认识到我添加到pom.xml中的新依赖项,所以我通过xml中的“依赖项视图”添加了它,这就成功了。谢谢您的回答。

如果您是因为“丢失工件”错误而来这里的,这对我很有用:

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4.1212</version>
    </dependency>

org.postgresql
postgresql
9.4.1212
对于PostgreSQL 10,我使用以下方法:

       <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.1.4</version>
        </dependency>

org.postgresql
postgresql
42.1.4

如果您使用intellj,什么对我也有效: 右键klick pom.xml->Maven->重新导入
不知道为什么它不下载复制粘贴上的工件。

我在发布问题之前试过了。我仍然收到类未找到异常。是否需要在pom.xml头中添加其他内容?我当前的标题:那么jar不存在还是没有加载?是的,jar不存在。它没有被下载你在构建过程中收到警告了吗?你有代理人吗?您是否检查了工件是否已下载?Tomcat管理连接?不,Tomcat是一个servlet引擎,但不是Glassfish、JBoss、Weblogic等应用服务器@khmarbaise感谢您的更正。我更新了响应。这不会改变任何事情,因为在这种情况下,最好是将驱动程序放入将要部署的war文件中。就这样,在我的例子中是:右键单击pom.xml->Maven->reloadproject