I created Maven project with IntelliJ IDEA, and followed this tutorial on how to connect PostgreSQL JDBC with Java. But, instead of changing pom.xml file, I went to Project Structure → Libraries, where I've added postgresql-42.6.0.jar.
Everything works fine, but I'm curious how is this dependency stored, since pom.xml file does not include postgresql-42.6.0.jar.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>dbproject</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
By default
.m2/repositoryfrom the user's home directory is used. To change it you can select the library destination while downloading:In general, it is not recommended to manage dependencies through
Project Structure→Librariesif build system like Maven/Gradle is used in the project because these settings might be lost after the project re-import triggered by the IDE Maven plugin.Consider adding this dependency to the
pom.xmldirectly.