Postgresql driver not found for maven dependency

耗尽温柔 提交于 2019-12-08 18:56:41

问题


I am running a spring project with maven and I am trying to use postgresql. I've added the dependency to pom.xml, but at tomcat startup, I get the following error:

java.lang.ClassNotFoundException: org.postgresql.Driver

pom.xml dependency:

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

It appears that Maven isn't downloading the jar so the Driver class is not found. Any ideas?


回答1:


When I put this in my pom, the artifact gets downloaded. Maybe you should clean your maven repository cache or delete the folders manually and retry.




回答2:


If you came here for "missing artifact" error, This worked for me:

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

For PostgreSQL 10 I use this:

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



回答3:


Maven wasn't recognizing the new dependency I have added to pom.xml, so I added it through 'Dependency view' from the xml and that did the trick. Thank you for your answers.




回答4:


You need to place a copy of the jar in the tomcat/lib folder.



来源:https://stackoverflow.com/questions/22325713/postgresql-driver-not-found-for-maven-dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!