Maven Version: 4
I am writing an annotation processing program that will take tableName and find their columns.
However, the program saying java.lang.ClassNotFoundException: org.postgresql.Driver.
I have added postgresql in pom.xml but still saying class not found. Tried a different postgresql dependency version too. When I create a simple maven program then it does not complain but in the case annotation processing project, I am getting this error.
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.23</version>
</dependency>
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/db-name?sslmode=disable","user","pass");
I even tried to load the postgresql jar using java but no lo luck. Tried these to load jar dynamically: How to load JAR files dynamically at Runtime?
Is there a scenario in the case of an annotation processing program that I am missing?
UPDATE I found the issue. annotation-processing-project is working fine. The other project (where I was adding annotation-processing-project as a dependency) also has postgresql dependency and the scope was runtime.
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
This was causing annotation-processing-project to find the postgresql.
Ho can I not edit client project and annotation-processor-project gets the postgresql dependency too??