如何将PostgreSQL驱动程序添加为Maven中的依赖项? [英] How do you add PostgreSQL Driver as a dependency in Maven?
问题描述
我试图在使用Hibernate和PostgreSQL数据库进行持久化时使用Maven开发Java应用程序。我不明白我应该如何将PostgreSQL驱动程序连接到我的应用程序。我发现你在Maven的pom.xml文件中添加了依赖项,该文件从远程存储库中找到jar,但其他jar是怎么回事? 解决方案
PostgreSQL驱动程序jar包含在Maven的Central Repository中:
对于PostgreSQL最高9.1,请使用:
<依赖性>
< groupId> postgresql< / groupId>
< artifactId> postgresql< / artifactId>
< version> VERSION< / version>
< /依赖关系>
或9.2+
<依赖性>
< groupId> org.postgresql< / groupId>
< artifactId> postgresql< / artifactId>
< version> VERSION< / version>
< /依赖关系>
(感谢@Caspar的更正)
I'm trying to develop a Java application with Maven while using Hibernate with a PostgreSQL database for persistence. I don't understand how I'm supposed to connect the PostgreSQL drivers to my application. I get that you add dependencies in Maven's pom.xml file, which finds jars from a remote repository, but what about other jars?
PostgreSQL drivers jars are included in Central Repository of Maven:
For PostgreSQL up to 9.1, use:
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>VERSION</version>
</dependency>
or for 9.2+
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>VERSION</version>
</dependency>
(Thanks to @Caspar for the correction)
这篇关于如何将PostgreSQL驱动程序添加为Maven中的依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!