Sot*_*lis 71 java postgresql hibernate maven
我正在尝试用Maven开发Java应用程序,同时使用Hibernate和PostgreSQL数据库进行持久化.我不明白我应该如何将PostgreSQL驱动程序连接到我的应用程序.我得到你在Maven的pom.xml文件中添加依赖项,该文件从远程存储库中找到jar,但是其他jar呢?
mad*_*th3 101
PostgreSQL驱动程序jar包含在Maven的Central Repository中:
对于高达9.1的PostgreSQL,使用:
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>VERSION</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
或9.2+
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>VERSION</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
(感谢@Caspar的更正)
fac*_*ias 25
更新最新版本:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你!
tft*_*ftd 17
根据您的PostgreSQL版本,您需要将postgresql驱动程序添加到您的pom.xml
文件中.
对于PostgreSQL 9.1,这将是:
<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/maven-v4_0_0.xsd">
<name>Your project name.</name>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
您可以从maven的中央存储库获取依赖项(以及任何其他依赖项)的代码
如果您使用的是postgresql 9.2+:
<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/maven-v4_0_0.xsd">
<name>Your project name.</name>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.1</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
您可以从以下位置查看最新版本和相关性片段:
归档时间: |
|
查看次数: |
115282 次 |
最近记录: |