2017-01-19 213 views
5

我想在我的Java應用程序中包含Postgres JDBC驅動程序,所以我將其添加爲maven依賴項。我選擇了this list的最後一個版本,這令我驚訝的是由Atlassian主持。 現在我收到此錯誤:未找到Postgres JDBC maven依賴關係

Missing artifact postgresql:postgresql:jar:9.4.1208-jdbc42-atlassian-hosted

我也試過不是由託管Atlassian的舊版本,但得到了同樣的錯誤! 是否有另一個適當的地方來獲得罐子?

這是我目前的pom.xml:

<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>PostgresListener</groupId> 
<artifactId>PostgresListener</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<build> 
    <sourceDirectory>src</sourceDirectory> 
    <plugins> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.5.1</version> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 
<dependencies> 
    <!-- https://mvnrepository.com/artifact/postgresql/postgresql --> 
    <dependency> 
     <groupId>postgresql</groupId> 
     <artifactId>postgresql</artifactId> 
     <version>9.4.1208-jdbc42-atlassian-hosted</version> 
    </dependency> 
</dependencies> 

+1

試試這個:http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.postgresql%22%20AND%20a%3A%22postgresql%22 – marstran

+0

可以你請張貼您的pom或依賴? – Dana

+0

你爲什麼試圖使用第三方依賴關係,而不是官方的postgresql JDBC maven dependency? –

回答

16

你到底在pom.xml文件有哪些?

應該是這樣的:

<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> 
<dependency> 
    <groupId>org.postgresql</groupId> 
    <artifactId>postgresql</artifactId> 
    <version>9.4.1212</version> 
</dependency> 

確保您使用org.postgresqlgroupId,而不是postgresql

+0

這一個工作,但你怎麼找到它?谷歌搜索不會讓我到它! – AHH

+0

@AHH https://jdbc.postgresql.org/download.html,使用鏈接指向Maven的鏈接http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.postgresql%22% 20於是%20A%3A%22postgresql%22 –

3

應該是:

<groupId>org.postgresql</groupId> 
    <artifactId>postgresql</artifactId> 
    </dependency> 

不要把版本。讓Maven自己做吧