【问题标题】:jHipster H2 console not workingjHipster H2 控制台不工作
【发布时间】:2017-07-12 10:09:02
【问题描述】:

我正在开发包含一些自定义实体的单体应用程序。当我通过管理选项卡访问 H2 控制台时。当我单击连接按钮时,它会导致应用程序重新启动。我无法理解为什么会这样。谁能帮我弄清楚。

在日志中:

DEBUG 971  --- [  Thread-51] com.mydomain.mytable1 : close successful. 
DEBUG 971  --- [  Thread-51] com.mydomain.mytable2 : close successful. 
DEBUG 971  --- [  Thread-51] com.mydomain.mytable3 : close successful. 
.
.

这导致通过控制台访问数据库时出现问题,但访问 API 时没有问题。执行查询也会产生 localhost refused to connect 。我是 jHipster 和 H2 的新手。

配置:

spring:
    profiles:
        active: dev
        include: swagger
    devtools:
        restart:
            enabled: true
        livereload:
            enabled: false # we use gulp + BrowserSync for livereload
    jackson:
        serialization.indent_output: true
    datasource:
        type: com.zaxxer.hikari.HikariDataSource
        url: jdbc:h2:file:./target/h2db/db/mydatabase;DB_CLOSE_DELAY=-1
        username: frothers
        password:
    h2:
        console:
            enabled: false
    jpa:
        database-platform: io.github.jhipster.domain.util.FixedH2Dialect
        database: H2
        show-sql: true
        properties:
            hibernate.id.new_generator_mappings: true
            hibernate.cache.use_second_level_cache: true
            hibernate.cache.use_query_cache: false
            hibernate.generate_statistics: true
            hibernate.cache.region.factory_class: io.github.jhipster.config.jcache.NoDefaultJCacheRegionFactory 

【问题讨论】:

    标签: h2 jhipster


    【解决方案1】:

    如果要访问 h2 控制台,为什么要禁用它?

     h2:
        console:
            enabled: false
    

    只需将enabled 转为true

    【讨论】:

    • 感谢您的回答。但我也已经尝试过了。那没有用。我最近尝试的是 spring:devtools:restart:enabled:false 。这解决了我的问题。请您简要解释一下可能是什么原因。
    • 可能是因为当您连接 h2 时,您更改了默认值,因此 h2 修改了target/classes/.h2.server.properties,从而触发了重新启动。如果是这种情况,则应排除此路径docs.spring.io/spring-boot/docs/current/reference/html/…
    • 感谢您的信息。我会用我的设置检查一下。
    猜你喜欢
    • 2020-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-08
    • 1970-01-01
    相关资源
    最近更新 更多