Microservices JHipster微服务集中化不使用Docker compose或任何Docker容器,需要帮助

Microservices JHipster微服务集中化不使用Docker compose或任何Docker容器,需要帮助,microservices,jhipster,spring-cloud-config,jhipster-registry,Microservices,Jhipster,Spring Cloud Config,Jhipster Registry,目前的情况是我正在尝试实现 我直接从git hub使用Jhipster注册应用程序作为Eureka注册中心和Spring云配置服务器(不过这是默认功能) 我需要将微服务应用程序的配置文件集中在Jhipster注册表中 所有这些我们都不需要使用Docker,因为当前项目不使用Docker。 为此,我对 bootstrap.yml文件,如下所示(通过本地文件系统的本机类型作为复合配置文件运行,因为我们没有访问生产git存储库的权限。因此选择仅使用dev/compositeprofile的文件系统。

目前的情况是我正在尝试实现

我直接从git hub使用Jhipster注册应用程序作为Eureka注册中心和Spring云配置服务器(不过这是默认功能)

我需要将微服务应用程序的配置文件集中在Jhipster注册表中

所有这些我们都不需要使用Docker,因为当前项目不使用Docker。 为此,我对 bootstrap.yml文件,如下所示(通过本地文件系统的本机类型作为复合配置文件运行,因为我们没有访问生产git存储库的权限。因此选择仅使用dev/compositeprofile的文件系统。 目前我的boostrap.yml如下所示

spring:
  application:
    name: jhipster-registry
  profiles:
    active: dev
    include: composite
  cloud:
    config:
      server:
        
        bootstrap: true
        composite:
          - type: native #git
            
            search-locations: file:/C:/Jhipster_Eureka/jhipster-registry-master/central-config/
            
        prefix: /config
      fail-fast: true
      
      name: jhipster-registry
      profile: composite 
我还在central config文件夹下创建了一个gateway.yml文件(gateway是我试图集中配置的微服务示例应用程序之一,无论是eureka客户端,数据源都是我生成的微服务网关应用程序中默认为application-dev.yml的所有内容。) 通过如下说明所有配置 gateway.yml

   server:
  port: 8888
management:
  health:
    diskspace:
      enabled: false
# ===================================================================
# JHipster Sample Spring Cloud Config.
# ===================================================================

# Property used on app startup to check the config server status

configserver:
  name: JHipster Registry config server
  status: Connected to the JHipster Registry config server!

# Default JWT secret token (to be changed in production!)
jhipster:
  security:
    authentication:
      jwt:
        # It is recommended to encrypt the secret key in Base64, using the `base64-secret` property.
        # For compabitibily issues with applications generated with older JHipster releases,
        # we use the non Base64-encoded `secret` property here.
        # secret: my-secret-key-which-should-be-changed-in-production-and-be-base64-encoded
        # The `base64-secret` property is recommended if you use JHipster v5.3.0+
        # (you can type `echo 'secret-key'|base64` on your command line)
        base64-secret: bXktc2VjcmV0LWtleS13aGljaC1zaG91bGQtYmUtY2hhbmdlZC1pbi1wcm9kdWN0aW9uLWFuZC1iZS1iYXNlNjQtZW5jb2RlZAo=

spring:
  profiles:
    active: dev
    include:
      - swagger

eureka:
  instance:
    prefer-ip-address: true
  client:
    service-url:
      defaultZone: http://admin:admin@localhost:8761/eureka/



  datasource:
  type: com.zaxxer.hikari.HikariDataSource
  url: jdbc:mysql://localhost:3306/conference?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
  username: root
  password: root
  hikari:
    poolName: Hikari
    auto-commit: false
    data-source-properties:
      cachePrepStmts: true
      prepStmtCacheSize: 250
      prepStmtCacheSqlLimit: 2048
      useServerPrepStmts: true

  jpa:
    show-sql: true
    liquibase:
      # Remove 'faker' if you do not want the sample data to be loaded automatically
      contexts: dev
问题1 如果我运行注册表,它会正常运行,不会出现任何问题。如果我尝试运行“网关”微服务应用程序,但没有定义它自己的配置文件(application-dev.yml)中提到的数据源定义,则在运行时失败

运行时期间的异常堆栈跟踪

2020-08-06 21:45:58.301  WARN 28804 --- [  restartedMain] 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.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
我很惊讶eureka实例是如何从gateway.yml文件而不是数据源中获取的,那么这里出了什么问题

问题2

在gateway.app中提到了yml
server.port:8888
,但它是spring cloud config server的端口还是micro service app的端口,例如8083 . 我观察到,如果我尝试将该端口从8888更改为8083,则在运行时会出现错误,无法找到发现客户端,这是什么问题,还是我仍然缺少一些配置方面的信息


请让我知道查询是否足够详细,现在是否可以响应。

使用JHipster注册表的JHipster micro services体系结构绝对不需要Docker,您的用例得到了很好的支持,您遇到的问题只是由于配置错误

gateway.yml
缩进不正确,因此
datasource
的属性名称不匹配,这就是为什么出现无法找到JDBC驱动程序的错误

<代码> EURKA块在“代码> > Spring 块完全破坏它,无论如何EURKA配置都被所有应用程序共享,所以它应该放在<代码>应用程序DEV.YLL 和<代码>应用程序PROD.YLL

gateway.yml
与环境存储库中的任何其他文件一样(
central config
文件夹,使用本机时),必须与本地application.yml文件的格式完全相同

如果您对YAML文件不满意,可以切换到普通属性

关于本机存储库中的文件命名,说明:

如果存储库是基于文件的,服务器将从application.yml(在所有客户端之间共享)和foo.yml(以foo.yml为准)创建一个环境。如果YAML文件中有指向Spring概要文件的文档,则这些文档将以更高的优先级应用(按所列概要文件的顺序)。如果存在特定于配置文件的YAML(或属性)文件,则这些文件的优先级也高于默认值

基本上,这意味着在
central config
文件夹中,您应该有以下文件:

  • application.yml
    :未设置配置文件时,所有应用程序共有的所有属性
  • application-dev.yml
    :设置开发人员配置文件时,所有应用程序共有的所有属性。在这里,您将放置开发人员的JWT机密,即开发人员Eureka服务器(通常为本地主机)的url
  • application-prod.yml
    :设置prod配置文件时,所有应用程序共有的所有属性。您将在此处放置prod的JWT机密,即prod Eureka服务器的url
  • gateway.yml
    :未设置配置文件时网关应用程序的所有属性
  • gateway-dev.yml
    :设置开发配置文件时网关应用程序的所有属性。这是放置开发数据源的位置
  • gateway-prod.yml
    :设置产品配置文件时网关应用程序的所有属性。这是放置产品数据源的位置
因此,当网关使用dev概要文件引导时,它将获得application.yml、application-dev.yml、gateway.yml和gateway-dev.yml的组合

只有遵循命名约定
{app name}-{profile}.yml


因此,命名一个文件
应用程序开发网关.yml
仅仅意味着所有应用程序都具有
开发网关
配置文件所共有的属性,这可能不是您的意思。

使用JHipster注册表的JHipster微服务体系结构绝对不需要Docker,您的用例得到了很好的支持,您遇到的问题也得到了解决这只是由于您的配置错误造成的

gateway.yml
缩进不正确,因此
datasource
的属性名称不匹配,这就是为什么出现无法找到JDBC驱动程序的错误

<代码> EURKA块在“代码> > Spring 块完全破坏它,无论如何EURKA配置都被所有应用程序共享,所以它应该放在<代码>应用程序DEV.YLL 和<代码>应用程序PROD.YLL

gateway.yml
与环境存储库中的任何其他文件一样(
central config
文件夹,使用本机时),必须与本地application.yml文件的格式完全相同

如果您对YAML文件不满意,可以切换到普通属性

Ab