获取连接关闭尝试使用JHipster应用程序连接到PostgreSQL数据库时出现异常(Getting Connection closed Exception when trying to conne

编程入门 行业动态 更新时间:2024-10-27 20:38:15
获取连接关闭尝试使用JHipster应用程序连接到PostgreSQL数据库时出现异常(Getting Connection closed Exception when trying to connect to PostgreSQL DB with JHipster Application)

当我尝试使用mvn spring-boot:run启动服务器时,出现此异常。 我之前做过一次mvn清洁。 我无法想象为什么会发生这种情况。 配置似乎是正确的。

liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: This connection has been closed. at liquibase.database.jvm.JdbcConnection.setAutoCommit(JdbcConnection.java:363) ~[liquibase-core-3.4.2.jar:na] at liquibase.database.AbstractJdbcDatabase.close(AbstractJdbcDatabase.java:1176) ~[liquibase-core-3.4.2.jar:na] at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:400) ~[liquibase-core-3.4.2.jar:na] at com.mycompany.myapp.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:63) ~[classes/:na] at com.mycompany.myapp.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$31(AsyncSpringLiquibase.java:49) ~[classes/:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_60] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_60] at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_60] Caused by: org.postgresql.util.PSQLException: This connection has been closed. at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:851) ~[postgresql-9.4-1203-jdbc42.jar:9.4] at org.postgresql.jdbc2.AbstractJdbc2Connection.setAutoCommit(AbstractJdbc2Connection.java:793) ~[postgresql-9.4-1203-jdbc42.jar:9.4] at com.zaxxer.hikari.proxy.ConnectionProxy.setAutoCommit(ConnectionProxy.java:334) ~[HikariCP-2.4.1.jar:na] at com.zaxxer.hikari.proxy.HikariConnectionProxy.setAutoCommit(HikariConnectionProxy.java) ~[HikariCP-2.4.1.jar:na] at liquibase.database.jvm.JdbcConnection.setAutoCommit(JdbcConnection.java:361) ~[liquibase-core-3.4.2.jar:na] ... 7 common frames omitted

这是我的应用程序dev.yaml:

# =================================================================== # Standard Spring Boot properties. # Full reference is available at: # http://docs.spring.io/spring-boot/docs/current/reference/html/common- application-properties.html # =================================================================== spring: profiles: active: dev devtools: restart: enabled: true livereload: enabled: false # we use Grunt + BrowserSync for livereload datasource: driver-class-name: org.postgresql.ds.PGSimpleDataSource url: jdbc:postgresql://localhost:3306/bowl name: username: postgres password: root jpa: database-platform: com.mycompany.myapp.domain.util.FixedPostgreSQL82Dialect database: POSTGRESQL show_sql: true properties: hibernate.cache.use_second_level_cache: true hibernate.cache.use_query_cache: false hibernate.generate_statistics: true hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory data: elasticsearch: cluster-name: cluster-nodes: properties: path: logs: target/elasticsearch/log data: target/elasticsearch/data mail: host: localhost messages: cache-seconds: 1 thymeleaf: cache: false liquibase: contexts: dev server: port: 8080 # =================================================================== # JHipster specific properties # =================================================================== jhipster: cache: # Hibernate 2nd level cache, used by CacheConfiguration timeToLiveSeconds: 3600 ehcache: maxBytesLocalHeap: 16M mail: # specific JHipster mail property, for standard properties see MailProperties from: test@localhost metrics: # DropWizard Metrics configuration, used by MetricsConfiguration jmx.enabled: true spark: enabled: false host: localhost port: 9999 graphite: enabled: false host: localhost port: 2003 prefix: test

这是我的application.yaml:

spring: jpa: open-in-view: false hibernate: ddl-auto: none naming-strategy: org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy messages: basename: classpath:/i18n/messages mvc: favicon: enabled: false thymeleaf: mode: XHTML security: basic: enabled: false # =================================================================== # JHipster specific properties # =================================================================== jhipster: async: corePoolSize: 2 maxPoolSize: 50 queueCapacity: 10000 #cors: #By default CORS are not enabled. Uncomment to enable. #allowed-origins: "*" #allowed-methods: GET, PUT, POST, DELETE, OPTIONS #allowed-headers: "*" #exposed-headers: #allow-credentials: true #max-age: 1800 mail: from: test@localhost security: rememberme: # security key (this key should be unique for your application, and kept secret) key: 7ba7d54b8c54ee10147cf46baa898c4cb7b4a597 swagger: title: test API description: test API documentation version: 0.0.1 termsOfServiceUrl: contact: license: licenseUrl:

I get this Exception when I try to start the server with mvn spring-boot:run. I did a mvn clean before. I can´t imagine why this would happen. The configuration seems to be correct.

liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: This connection has been closed. at liquibase.database.jvm.JdbcConnection.setAutoCommit(JdbcConnection.java:363) ~[liquibase-core-3.4.2.jar:na] at liquibase.database.AbstractJdbcDatabase.close(AbstractJdbcDatabase.java:1176) ~[liquibase-core-3.4.2.jar:na] at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:400) ~[liquibase-core-3.4.2.jar:na] at com.mycompany.myapp.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:63) ~[classes/:na] at com.mycompany.myapp.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$31(AsyncSpringLiquibase.java:49) ~[classes/:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_60] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_60] at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_60] Caused by: org.postgresql.util.PSQLException: This connection has been closed. at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:851) ~[postgresql-9.4-1203-jdbc42.jar:9.4] at org.postgresql.jdbc2.AbstractJdbc2Connection.setAutoCommit(AbstractJdbc2Connection.java:793) ~[postgresql-9.4-1203-jdbc42.jar:9.4] at com.zaxxer.hikari.proxy.ConnectionProxy.setAutoCommit(ConnectionProxy.java:334) ~[HikariCP-2.4.1.jar:na] at com.zaxxer.hikari.proxy.HikariConnectionProxy.setAutoCommit(HikariConnectionProxy.java) ~[HikariCP-2.4.1.jar:na] at liquibase.database.jvm.JdbcConnection.setAutoCommit(JdbcConnection.java:361) ~[liquibase-core-3.4.2.jar:na] ... 7 common frames omitted

This is my application-dev.yaml:

# =================================================================== # Standard Spring Boot properties. # Full reference is available at: # http://docs.spring.io/spring-boot/docs/current/reference/html/common- application-properties.html # =================================================================== spring: profiles: active: dev devtools: restart: enabled: true livereload: enabled: false # we use Grunt + BrowserSync for livereload datasource: driver-class-name: org.postgresql.ds.PGSimpleDataSource url: jdbc:postgresql://localhost:3306/bowl name: username: postgres password: root jpa: database-platform: com.mycompany.myapp.domain.util.FixedPostgreSQL82Dialect database: POSTGRESQL show_sql: true properties: hibernate.cache.use_second_level_cache: true hibernate.cache.use_query_cache: false hibernate.generate_statistics: true hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory data: elasticsearch: cluster-name: cluster-nodes: properties: path: logs: target/elasticsearch/log data: target/elasticsearch/data mail: host: localhost messages: cache-seconds: 1 thymeleaf: cache: false liquibase: contexts: dev server: port: 8080 # =================================================================== # JHipster specific properties # =================================================================== jhipster: cache: # Hibernate 2nd level cache, used by CacheConfiguration timeToLiveSeconds: 3600 ehcache: maxBytesLocalHeap: 16M mail: # specific JHipster mail property, for standard properties see MailProperties from: test@localhost metrics: # DropWizard Metrics configuration, used by MetricsConfiguration jmx.enabled: true spark: enabled: false host: localhost port: 9999 graphite: enabled: false host: localhost port: 2003 prefix: test

This is my application.yaml:

spring: jpa: open-in-view: false hibernate: ddl-auto: none naming-strategy: org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy messages: basename: classpath:/i18n/messages mvc: favicon: enabled: false thymeleaf: mode: XHTML security: basic: enabled: false # =================================================================== # JHipster specific properties # =================================================================== jhipster: async: corePoolSize: 2 maxPoolSize: 50 queueCapacity: 10000 #cors: #By default CORS are not enabled. Uncomment to enable. #allowed-origins: "*" #allowed-methods: GET, PUT, POST, DELETE, OPTIONS #allowed-headers: "*" #exposed-headers: #allow-credentials: true #max-age: 1800 mail: from: test@localhost security: rememberme: # security key (this key should be unique for your application, and kept secret) key: 7ba7d54b8c54ee10147cf46baa898c4cb7b4a597 swagger: title: test API description: test API documentation version: 0.0.1 termsOfServiceUrl: contact: license: licenseUrl:

最满意答案

问题是由实体造成的。 我必须以特定的顺序生成关系以生成正确的液化酶更新日志。 顺序是:

many-to-one -> one-to-one (owner) -> many-to-many (owner) -> all others

弄清楚这确实花了我半个星期。 愚蠢的我。

The problem was caused by the entities. I had to generate the relationships in a specific order to generate correct liquibase changelogs. The order goes:

many-to-one -> one-to-one (owner) -> many-to-many (owner) -> all others

Figuring this out really did cost me half a week. Stupid me.

更多推荐

本文发布于:2023-08-05 09:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1431261.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   应用程序   异常   数据库   PostgreSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!