Arya
Arya

Reputation: 8965

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?

Upvotes: 13

Views: 6442

Answers (1)

Ken Chan
Ken Chan

Reputation: 90427

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>

Upvotes: 19

Related Questions