Postgresql driver not found for maven dependency

I am running a spring project with maven and I am trying to use postgresql. I added a dependency on pom.xml, but when I start tomcat, 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> 

Maven doesn't seem to load the jar, so the Driver class was not found. Any ideas?

+7
spring maven postgresql dependencies driver
source share
4 answers

Maven did not recognize the new dependency that I added to pom.xml, so I added it through the "dependency view" from xml and did the trick. Thank you for your responses.

0
source share

If you came here for a “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> 
+1
source share

When I put this in my pom, the artifact loads. Perhaps you should clear the maven cache or delete folders manually and try again.

0
source share

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

-one
source share

All Articles