【问题标题】:How to resolve this - Failed to collect dependencies at org.postgresql:postgresql:jar:42.2.4如何解决这个问题 - 无法在 org.postgresql:postgresql:jar:42.2.4 收集依赖项
【发布时间】:2021-05-31 15:19:10
【问题描述】:
Could not resolve dependencies for project com.howtodoinjava:demo:jar:0.0.1-SNAPSHOT: 
Failed to collect dependencies at org.postgresql:postgresql:jar:42.2.4: Failed to read artifact descriptor for org.postgresql:postgresql:jar:42.2.4: Could not transfer artifact org.postgresql:postgresql:pom:42.2.4 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/postgresql/postgresql/42.2.4/postgresql-42.2.4.pom: Unknown host No such host is known (repo.maven.apache.org) -> [Help 1]

【问题讨论】:

  • 确保在项目类路径中添加了所有必需的 jar 或在 pom.xml 中有条目
  • No such host is known: 你的网络有问题。
  • 需要验证的常见事项:您可以在浏览器中访问该网站吗?是否正在使用任何限制您的代码来解析该主机的 VPN?你在 pom 文件中的 repo 主机是什么?您是否在 .m2 文件夹中使用了具有 repo 主机的设置文件,并且不允许访问 repo.maven.apache.org?您的代码是否在代理后面?

标签: java spring postgresql spring-boot jdbc


【解决方案1】:

分享您的pom.xmlapplication.properties,无论如何它应该是这样的:

  • Pom 文件

<dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
</dependency>
  • 应用程序操作
spring.datasource.url=jdbc:postgresql://localhost:5432/yourdatabasename
spring.datasource.username=postgres (this is default username)
spring.datasource.password=yourpassword

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

spring.jpa.hibernate.ddl-auto=update

【讨论】:

    猜你喜欢
    • 2011-11-07
    • 2012-11-18
    • 1970-01-01
    • 2019-02-23
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 2021-01-04
    • 2017-04-10
    相关资源
    最近更新 更多