Jhipster 在启动时使用下巴 MariaDB 插件讨论 Heroku 问题

Posted

技术标签:

【中文标题】Jhipster 在启动时使用下巴 MariaDB 插件讨论 Heroku 问题【英文标题】:Jhipster on Heroku problem with jawsdb MariaDB addon at startup 【发布时间】:2021-02-24 17:17:44 【问题描述】:

我正在尝试使用 maven、angular 和 maria-db 部署一个基本的 jhipster 应用程序。按照 jhipster 指南,我配置了应用程序并部署了本地编译的项目。所有上传都正常,但在启动过程中我收到了这个问题:

2020-11-12T16:15:57.719036+00:00 app[web.1]: 2020-11-12 16:15:57.701  INFO 4 --- [           main] com.gate42.advpoint.AdvpointApp          : Starting AdvpointApp on cd5ce05d-5f60-4f27-a236-8c53eab442f9 with PID 4 (/app/target/advpoint-0.0.1-SNAPSHOT.jar started by u32323 in /app)
2020-11-12T16:15:57.735456+00:00 app[web.1]: 2020-11-12 16:15:57.728  INFO 4 --- [           main] com.gate42.advpoint.AdvpointApp          : The following profiles are active: prod,heroku
2020-11-12T16:16:05.779094+00:00 app[web.1]: 2020-11-12 16:16:05.776 ERROR 4 --- [           main] com.zaxxer.hikari.HikariConfig           : Failed to load driver class com.mysql.cj.jdbc.Driver from HikariConfig class classloader org.springframework.boot.loader.LaunchedURLClassLoader@6d00a15d
2020-11-12T16:16:05.781901+00:00 app[web.1]: 2020-11-12 16:16:05.781  WARN 4 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthContributorAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource
2020-11-12T16:16:05.820063+00:00 app[web.1]: 2020-11-12 16:16:05.819 ERROR 4 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :
2020-11-12T16:16:05.820065+00:00 app[web.1]:
2020-11-12T16:16:05.820066+00:00 app[web.1]: ***************************
2020-11-12T16:16:05.820066+00:00 app[web.1]: APPLICATION FAILED TO START
2020-11-12T16:16:05.820067+00:00 app[web.1]: ***************************
2020-11-12T16:16:05.820067+00:00 app[web.1]:
2020-11-12T16:16:05.820068+00:00 app[web.1]: Description:
2020-11-12T16:16:05.820068+00:00 app[web.1]:
2020-11-12T16:16:05.820069+00:00 app[web.1]: Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
2020-11-12T16:16:05.820069+00:00 app[web.1]:
2020-11-12T16:16:05.820070+00:00 app[web.1]: Property: driverclassname
2020-11-12T16:16:05.820071+00:00 app[web.1]: Value: com.mysql.cj.jdbc.Driver
2020-11-12T16:16:05.820072+00:00 app[web.1]: Origin: "driverClassName" from property source "source"
2020-11-12T16:16:05.820073+00:00 app[web.1]: Reason: Failed to load driver class com.mysql.cj.jdbc.Driver in either of HikariConfig class loader or Thread context classloader
2020-11-12T16:16:05.820073+00:00 app[web.1]:
2020-11-12T16:16:05.820073+00:00 app[web.1]: Action:
2020-11-12T16:16:05.820074+00:00 app[web.1]:
2020-11-12T16:16:05.820074+00:00 app[web.1]: Update your application's configuration
2020-11-12T16:16:05.820074+00:00 app[web.1]:
2020-11-12T16:16:05.957077+00:00 heroku[web.1]: Process exited with status 1
2020-11-12T16:16:06.003260+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-12T16:42:37.888949+00:00 heroku[web.1]: State changed from crashed to starting

我的 heroku 配置是 application-heroku.yml 并且是自动创建的:

eureka:
  instance:
    hostname: advpoint.herokuapp.com
    non-secure-port: 80
    prefer-ip-address: false

spring:
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: $JDBC_DATABASE_URL
    username: $JDBC_DATABASE_USERNAME
    password: $JDBC_DATABASE_PASSWORD
    hikari:
      maximumPoolSize: 8

数据库连接信息是由jawsdb-addon 自动创建的。 我能做些什么来解决这个问题? 感谢所有会回答的人。

【问题讨论】:

你试过了吗? ***.com/questions/52804228/… 【参考方案1】:

为了解决这个问题,我在我的 pom 文件中添加了这个依赖项:

<dependency>
     <groupId>mysql</groupId>
     <artifactId>mysql-connector-java</artifactId>
</dependency>

我认为在 heroku 配置期间它是自动添加的。 我不知道这是否是一个问题,但我认为这可以在使用时由jawsdb-addon 自动完成。

【讨论】:

我不确定是否是jawsdb-addon 的问题,它不应该负责管理您的项目依赖项;我宁愿认为这是 generator-jhipster 或其 heroku 子生成器中的错误。请随时在 github 上报告它并提供更多详细信息。此外,Jhipster 中不推荐使用 MySQL 以支持 PostgreSQL

以上是关于Jhipster 在启动时使用下巴 MariaDB 插件讨论 Heroku 问题的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Jhipster 中配置热重载?

JHipster 和 mongodb:创建名称为“mongobee”的 bean 时出错

JHipster - 在 AWS Beanstalk 中发布部署 Jhipster 注册表

使用opencv检测没有眉毛和下巴的人脸

jhipster 生成的应用程序可以在没有纱线启动的情况下正常工作,只需在 8080 上运行,那么为啥要在端口 9000 上运行

启动 mariadb 时出错 - 没有这样的过程