Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.postgresql.util.PGobject not available in org.postgresql

I'm using Spring boot 2.1.5.RELEASE and I have the following dependency in my pom.xml

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <scope>runtime</scope>
</dependency>

But org.postgresql.util.PGobject is not found. In another non-spring boot project I have the following dependency

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

and org.postgresql.util.PGobject is available for use.

Any idea why org.postgresql.util.PGobject is not found in the spring boot project?

like image 702
Arya Avatar asked Jun 23 '19 18:06

Arya


1 Answers

Because you set the Postgresql JDBC driver in the runtime scope , which has the following behaviour :

This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.

It is not in the compile classpath causing its class cannot be found during compile. You should change it to compile scope , which is the default scope so you can simply leave out <scope> :

 <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
</dependency>
like image 197
Ken Chan Avatar answered Nov 15 '22 07:11

Ken Chan