How do you add PostgreSQL Driver as a dependency in Maven?

前端 未结 5 1985
深忆病人
深忆病人 2020-12-13 05:29

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 P

5条回答
  •  一整个雨季
    2020-12-13 06:06

    Depending on your PostgreSQL version you would need to add the postgresql driver to your pom.xml file.

    For PostgreSQL 9.1 this would be:

    
    
        Your project name.
        
            
                postgresql
                postgresql
                9.1-901-1.jdbc4
            
        
    
    

    You can get the code for the dependency (as well as any other dependency) from maven's central repository

    If you are using postgresql 9.2+:

    
    
        Your project name.
        
            
                org.postgresql
                postgresql
                42.2.1
            
        
    
    

    You can check the latest versions and dependency snippets from:

    • http://mvnrepository.com/artifact/postgresql/postgresql
    • http://mvnrepository.com/artifact/org.postgresql/postgresql

提交回复
热议问题