【问题标题】:Can't save data with postgreSQL in prod profile无法在 prod 配置文件中使用 postgreSQL 保存数据
【发布时间】:2016-11-16 04:11:57
【问题描述】:

当我使用 prod 配置文件启动我的服务器时,我可以在我的 JHipster 应用程序中与管理员 admin 连接,但是当我想创建一个新对象时我无法保存任何数据(我有一个 InternalServerError)。然而,在具有相同数据库(PostgreSQL)的开发配置文件中,它运行良好。

此外,在使用 prod profile 来了解问题时,我不知道如何获取日志。

我可以为 prod 配置文件添加配置文件

# ===================================================================
# Spring Boot configuration for the "prod" profile.
#
# This configuration overrides the application.yml file.
# ===================================================================

# ===================================================================
# Standard Spring Boot properties.
# Full reference is available at:
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ===================================================================


spring:
    devtools:
        restart:
            enabled: false
        livereload:
            enabled: false
    datasource:
        url: jdbc:postgresql://localhost:5432/vraiJhipster
        name:
        username: vraiJhipster
        password:
    jpa:
        database-platform: com.mycompany.myapp.domain.util.FixedPostgreSQL82Dialect
        database: POSTGRESQL
        show_sql: false
        properties:
            hibernate.cache.use_second_level_cache: true
            hibernate.cache.use_query_cache: false
            hibernate.generate_statistics: false
            hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
    data:
        elasticsearch:
            cluster-name:
            cluster-nodes: localhost:9300
    mail:
        host: localhost
        port: 25
        username:
        password:
    thymeleaf:
        cache: true

liquibase:
    contexts: prod

server:
    port: 8080
    compression:
        enabled: true
        mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json
        min-response-size: 1024

# ===================================================================
# JHipster specific properties
# ===================================================================

jhipster:
    http:
        cache: # Used by the CachingHttpHeadersFilter
            timeToLiveInDays: 1461
    cache: # Hibernate 2nd level cache, used by CacheConfiguration
        timeToLiveSeconds: 3600
        ehcache:
            maxBytesLocalHeap: 256M
    security:
        rememberMe:
            # security key (this key should be unique for your application, and kept secret)
            key: *****************************************
    mail: # specific JHipster mail property, for standard properties see MailProperties
        from: vraiJhipster@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: vraiJhipster
        logs: # Reports Dropwizard metrics in the logs
            enabled: false
            reportFrequency: 60 # in seconds
    logging:
        logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
            enabled: false
            host: localhost
            port: 5000
            queueSize: 512
    swagger: # swagger is disabled. It can be disabled by pasing 'no-swagger' profile at run time as well
        enabled: false

谢谢。

如果您需要有关我的配置的信息,可以询问。

【问题讨论】:

  • 请在 GitHub 上分享更具体的信息,例如 Stacktraces、代码片段,甚至是完整的示例应用程序。
  • 如何在 prod 配置文件中运行您的应用程序:mvn、可执行 jar、在外部服务器中部署的 war?哪个 JHipster 版本?
  • @GaëlMarziou 我使用 Jhipster 3.4.2(最新版本),我用 spring 启动服务器,所以我猜它适用于 mvn。
  • 对不起,我不明白您所说的“我用弹簧启动服务器”是什么意思。您的意思是从命令行作为可执行 jar 启动应用程序还是使用“java -jar”? docs.spring.io/spring-boot/docs/1.3.x/reference/htmlsingle/…
  • 其实我用的是 mvn -Pprod

标签: postgresql spring-boot spring-data-jpa jhipster


【解决方案1】:

我发现问题实际上是 elasticSearch。当我在生产模式下使用 JHipster 时,默认配置使用端口 9300 上的 elasticSearch。但我的计算机上没有运行任何 elasticSearch。所以我将 elasticSearch 配置从 dev 配置文件复制粘贴到 prod 配置文件。

data:
    elasticsearch:
        cluster-name:
        cluster-nodes:
        properties:
            path:
              logs: target/elasticsearch/log
              data: target/elasticsearch/data

【讨论】:

    猜你喜欢
    • 2015-02-23
    • 2019-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-11
    • 2016-12-25
    相关资源
    最近更新 更多