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?

有帮助吗?

解决方案 5

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.

其他提示

What also worked for me if you are on intellj: right klick pom.xml->Maven->Reimport Don't know why it doesn't download the artifact on copy paste.

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.

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>

Try to rebuild the artifact, most likely only the added dependency was not included there

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top