Java 通过弹簧靴与postgres连接

Java 通过弹簧靴与postgres连接,java,postgresql,spring-boot,gradle,database-connection,Java,Postgresql,Spring Boot,Gradle,Database Connection,我有一个Postgres服务器运行在127.0.0.1:51282上。当我构建这个项目时,我得到org.postgresql.util.PSQLException并告知连接尝试失败。 以下是我的配置: application.properties: spring.output.ansi.enabled=ALWAYS spring.datasource.url=jdbc:postgresql://172.0.0.1:51282/postgres spring.datasource.username

我有一个Postgres服务器运行在127.0.0.1:51282上。当我构建这个项目时,我得到org.postgresql.util.PSQLException并告知连接尝试失败。 以下是我的配置:

application.properties:
spring.output.ansi.enabled=ALWAYS
spring.datasource.url=jdbc:postgresql://172.0.0.1:51282/postgres
spring.datasource.username=postgres
spring.datasource.password=kurwa123
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=create
dependencies { 
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 
    implementation 'org.springframework.boot:spring-boot-starter-web' 
    developmentOnly 'org.springframework.boot:spring-boot-devtools' 
    compile group: 'org.postgresql', name: 'postgresql', version: '42.2.18' 
    testImplementation('org.springframework.boot:spring-boot-starter-test') { 
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 
    }
}
Postgres控制台:

渐变配置:

application.properties:
spring.output.ansi.enabled=ALWAYS
spring.datasource.url=jdbc:postgresql://172.0.0.1:51282/postgres
spring.datasource.username=postgres
spring.datasource.password=kurwa123
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=create
dependencies { 
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 
    implementation 'org.springframework.boot:spring-boot-starter-web' 
    developmentOnly 'org.springframework.boot:spring-boot-devtools' 
    compile group: 'org.postgresql', name: 'postgresql', version: '42.2.18' 
    testImplementation('org.springframework.boot:spring-boot-starter-test') { 
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 
    }
}

非常感谢您的回答

{implementation'org.springframework.boot:springboot-starter数据jpa'implementation'org.springframework.boot:springboot-starter-thymeleaf'implementation'org.springframework.boot:spring-boot-starter-web'developmentOnly'org.springframework.boot:springboot-devtools'编译组:'org.postgresql','postgresql','8'testImplementation('org.springframework.boot:springbootstartertest'){排除组:'org.junit.vintage',模块:'junit vintage engine'}这些是我的依赖项能否提供完整的stacktrace?您是否尝试使用pgAdmin或其他工具进行连接?只是为了确保可以连接。另外,在图片中,我看到您使用
db
作为数据库名称。使用提供的配置,Spring可能找不到您的数据库。您应该在中连接到127.0.0.1而不是应用程序属性中的172.0.0.1。这是完整的stacktrace