HikariPool-1 -使用SpringBoot、Hibernate和JPA系统信息库初始化池时出现异常

wnrlj8wa  于 2022-12-04  发布在  Spring
关注(0)|答案(1)|浏览(186)

HikariPool-1 -尝试运行spring-boot应用程序时,池初始化期间出现异常错误。运行mvn spring-boot:run命令时,日志显示存储库已初始化,服务器已启动并处于运行状态,但在hikari池初始化期间抛出异常错误!
可以使用pgAdmin连接到DB,但无法从应用程序连接。来自www.example.com的代码application.properties如下。

spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
spring.datasource.url= jdbc:postgresql:/34.93.135.89:5433/mtt_04_dec_22
spring.datasource.username= postgres
spring.datasource.password= justdoit@mtt
spring.jpa.hibernate.ddl-auto= none
spring.datasource.testWhileIdle=true
spring.datasource.test-on-borrow=true
spring.datasource.hikari.connectionTimeout=30000 
spring.datasource.hikari.maxLifetime=60000
spring.datasource.hikari.maximum-pool-size=30
spring.jpa.open-in-view=false

和Hikari调试日志

PersistenceUnitInfo [name: default]
2022-12-02 11:30:24.569  INFO 14176 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.15.Final
2022-12-02 11:30:24.791  INFO 14176 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2022-12-02 11:30:24.947 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : HikariPool-1 - configuration:
2022-12-02 11:30:24.950 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : allowPoolSuspension.............false
2022-12-02 11:30:24.950 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : autoCommit......................true
2022-12-02 11:30:24.951 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : catalog.........................none
2022-12-02 11:30:24.951 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : connectionInitSql...............none
2022-12-02 11:30:24.951 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : connectionTestQuery.............none
2022-12-02 11:30:24.952 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : connectionTimeout...............30000
2022-12-02 11:30:24.952 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : dataSource......................none
2022-12-02 11:30:24.952 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : dataSourceClassName.............none
2022-12-02 11:30:24.952 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : dataSourceJNDI..................none
2022-12-02 11:30:24.953 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : dataSourceProperties............{password=<masked>}
2022-12-02 11:30:24.953 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : driverClassName................."org.postgresql.Driver"
2022-12-02 11:30:24.953 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : exceptionOverrideClassName......none
2022-12-02 11:30:24.954 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : healthCheckProperties...........{}
2022-12-02 11:30:24.954 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : healthCheckRegistry.............none
2022-12-02 11:30:24.954 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : idleTimeout.....................600000
2022-12-02 11:30:24.954 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : initializationFailTimeout.......1
2022-12-02 11:30:24.955 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : isolateInternalQueries..........false
2022-12-02 11:30:24.955 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : jdbcUrl.........................jdbc:postgresql:/35.200.211.39:5432/mtt_04_dec_22
2022-12-02 11:30:24.955 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : leakDetectionThreshold..........0
2022-12-02 11:30:24.955 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : maxLifetime.....................30000
2022-12-02 11:30:24.956 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : maximumPoolSize.................30
2022-12-02 11:30:24.956 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : metricRegistry..................none
2022-12-02 11:30:24.956 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : metricsTrackerFactory...........none
2022-12-02 11:30:24.956 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : minimumIdle.....................30
2022-12-02 11:30:24.956 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : password........................<masked>
2022-12-02 11:30:24.957 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : poolName........................"HikariPool-1"
2022-12-02 11:30:24.957 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : readOnly........................false
2022-12-02 11:30:24.957 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : registerMbeans..................false
2022-12-02 11:30:24.957 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : scheduledExecutor...............none
2022-12-02 11:30:24.957 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : schema..........................none
2022-12-02 11:30:24.958 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : threadFactory...................internal
2022-12-02 11:30:24.958 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : transactionIsolation............default
2022-12-02 11:30:24.958 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : username........................"postgres"
2022-12-02 11:30:24.959 DEBUG 14176 --- [         task-1] com.zaxxer.hikari.HikariConfig           : validationTimeout...............5000

控制台上的异常如下所示:

HikariPool-1 - Exception during pool initialization.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.0.RELEASE)

2022-12-02 09:26:51.258  INFO 14888 --- [           main] org.sadisha.backend.service.Main         : Starting Main on DESKTOP-991KNCS with PID 14888 (C:\mttbe\mtt-be\target\classes started by Admin in C:\mttbe\mtt-be)
2022-12-02 09:26:51.265  INFO 14888 --- [           main] org.sadisha.backend.service.Main         : No active profile set, falling back to default profiles: default
2022-12-02 09:26:52.481  INFO 14888 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2022-12-02 09:26:52.715  INFO 14888 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 220ms. Found 11 JPA repository interfaces.
2022-12-02 09:26:53.776  INFO 14888 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-12-02 09:26:53.793  INFO 14888 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-12-02 09:26:53.794  INFO 14888 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.35]
2022-12-02 09:26:54.042  INFO 14888 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-12-02 09:26:54.043  INFO 14888 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2655 ms
2022-12-02 09:26:54.178  INFO 14888 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2022-12-02 09:26:57.285 ERROR 14888 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:303) ~[postgresql-42.2.18.jar:42.2.18]
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-42.2.18.jar:42.2.18]
        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225) ~[postgresql-42.2.18.jar:42.2.18]
        at org.postgresql.Driver.makeConnection(Driver.java:465) ~[postgresql-42.2.18.jar:42.2.18]
        at org.postgresql.Driver.connect(Driver.java:264) ~[postgresql-42.2.18.jar:42.2.18]
        at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.5.jar:na]
        at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358) ~[HikariCP-3.4.5.jar:na]
        at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-3.4.5.jar:na]
        at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477) ~[HikariCP-3.4.5.jar:na]
        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560) ~[HikariCP-3.4.5.jar:na]
        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-3.4.5.jar:na]
        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-3.4.5.jar:na]
        at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158) ~[spring-jdbc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
        at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116) ~[spring-jdbc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
        at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79) ~[spring-jdbc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:324) ~[spring-jdbc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
        at org.springframework.boot.jdbc.EmbeddedDatabaseConnection.isEmbedded(EmbeddedDatabaseConnection.java:120) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.isEmbedded(DataSourceInitializer.java:137) ~[spring-boot-autoconfigure-2.3.0.RELEASE.jar:2.3.0.RELEASE]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.isEnabled(DataSourceInitializer.java:129) ~[spring-boot-autoconfigure-2.3.0.RELEASE.jar:2.3.0.RELEASE]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.createSchema(DataSourceInitializer.java:96) ~[spring-boot-autoconfigure-2.3.0.RELEASE.jar:2.3.0.RELEASE]
dgtucam1

dgtucam11#

在你的application.properties
更改此设置:

spring.datasource.url=jdbc:postgresql:/34.93.135.89:5433/mtt_04_dec_22

postgresql默认地址是5432而不是5433。这可能是错误的原因
这里是你写:34.93.135.89:5433

相关问题