Maven에서 PostgreSQL 드라이버를 종속성으로 추가하는 방법은 무엇입니까?
지속성을 위해 PostgreSQL 데이터베이스와 함께 Hibernate를 사용하는 동안 Maven으로 Java 응용 프로그램을 개발하려고합니다. PostgreSQL 드라이버를 내 응용 프로그램에 연결하는 방법을 이해하지 못합니다. 원격 저장소에서 jar를 찾는 Maven의 pom.xml 파일에 종속성을 추가했지만 다른 jar는 어떻습니까?
PostgreSQL 드라이버 jar는 Maven의 중앙 저장소에 포함되어 있습니다.
9.1까지의 PostgreSQL의 경우 다음을 사용합니다.
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>VERSION</version>
</dependency>
또는 9.2 이상
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>VERSION</version>
</dependency>
(수정을 위해 @Caspar에게 감사드립니다)
최신 릴리스 업데이트 :
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.1</version>
</dependency>
도움이 되었기를 바랍니다.
PostgreSQL 버전에 따라 pom.xml
파일에 postgresql 드라이버를 추가해야 합니다.
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>
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>
다음에서 최신 버전 및 종속성 스 니펫을 확인할 수 있습니다.
- http://mvnrepository.com/artifact/postgresql/postgresql
- http://mvnrepository.com/artifact/org.postgresql/postgresql
PostgreSQL 사이트, 2016 년 2 월 4 일 ( https://jdbc.postgresql.org/download.html ) :
"This is the current version of the driver. Unless you have unusual requirements (running old applications or JVMs), this is the driver you should be using. It supports Postgresql 7.2 or newer and requires a 1.6 or newer JVM. It contains support for SSL and the javax.sql package. If you are using the 1.6 then you should use the JDBC4 version. If you are using 1.7 then you should use the JDBC41 version. If you are using 1.8 then you should use the JDBC42 versionIf you are using a java version older than 1.6 then you will need to use a JDBC3 version of the driver, which will by necessity not be current"
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
'developer tip' 카테고리의 다른 글
jquery UI-정렬 가능 : 정렬 가능한 요소 내에서 아이콘 '핸들'로 드래그 (0) | 2020.11.01 |
---|---|
SQL Server 2008의 날짜에서 연도 만 추출하는 방법은 무엇입니까? (0) | 2020.11.01 |
Swift에서 간단한 페이드 인 애니메이션을 만드시겠습니까? (0) | 2020.11.01 |
STL의 벡터에 맵 값 복사 (0) | 2020.10.31 |
django @login_required 수퍼 유저 용 데코레이터 (0) | 2020.10.31 |