当前位置: 首页 > 知识库问答 >
问题:

Spring Boot管理客户端在存在上下文路径时仅显示详细信息

郏正信
2023-03-14

我运行启动管理服务器与尤里卡发现。

管理服务器:

plugins {
    id 'org.springframework.boot' version '2.1.7.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

ext {
    set('springCloudVersion', "Greenwich.SR2")
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    implementation 'de.codecentric:spring-boot-admin-starter-server:2.1.6'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

管理服务器应用程序Yml:

spring:
  boot.admin.discovery.converter.management-context-path: /admin
  application:
    name: spring-boot-admin-sample-eureka

eureka:   #<1>
  instance:
    leaseRenewalIntervalInSeconds: 10
    health-check-url-path: /admin/health
    metadata-map:
      startup: ${random.int}    #needed to trigger info and endpoint update after restart
      management.context-path: ${management.endpoints.web.base-path}
      info.path: ${management.endpoints.web.base-path}/info
  client:
    registryFetchIntervalSeconds: 5
    serviceUrl:
      defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8761}/eureka/

management:
  endpoints:
    web:
      exposure:
        include: "*"  #<2>
  endpoint:
    health:
      show-details: ALWAYS

客户:

plugins {
    id 'org.springframework.boot' version '2.1.7.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

ext {
    set('springCloudVersion', "Greenwich.SR2")
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    // https://mvnrepository.com/artifact/org.jolokia/jolokia-core
    compile group: 'org.jolokia', name: 'jolokia-core', version: '1.6.2'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.security:spring-security-test'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

应用Yml

server:
  port: 8083
  servlet:
    context-path: /mypath

#management config
eureka:
  instance:
    leaseRenewalIntervalInSeconds: 10
    health-check-url-path: /admin/health
    statusPageUrlPath:  /admin/info
    metadata-map:
      startup: ${random.int}    #needed to trigger info and endpoint update after restart
      management.context-path: ${management.endpoints.web.base-path}
      info.path: ${management.endpoints.web.base-path}/info
  client:
    registryFetchIntervalSeconds: 5
    serviceUrl:
      defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8761}/eureka/

management:
  endpoint:
    health:
      show-details: ALWAYS
  endpoints:
    web:
      base-path: /admin
      exposure:
        include: '*'

security.basic.enabled: false

info:
  component: Processor2
  build:
    name:           Processor2
    description:    Processor to Roll up PP
    version:        1
  eureka:
    region: ${eureka.client.region}
    zone: ${eureka.instance.metadataMap.zone}
    us-east-1b: discovery1
    us-east-1c: discovery2
    us-east-1e: discovery3
dp:
  username: admin
  password: admin123

spring:
  application.name: procerssor2
  jmx:
    enabled: true

  boot:
    admin:
      client:
        instance:
          service-url: /mypath

health:
  config:
    enabled: false

由于上下文路径的原因,引导管理员只是显示了详细信息。我核实了http://localhost:8080/applications.它看起来像下面。

{
    "name": "PROCERSSOR2",
    "buildVersion": null,
    "status": "UP",
    "statusTimestamp": "2019-08-28T18:32:19.854Z",
    "instances": [
      {
        "id": "804f35b9b73d",
        "version": 1,
        "registration": {
          "name": "PROCERSSOR2",
          "managementUrl": "http://192.168.0.8:8083/admin",
          "healthUrl": "http://192.168.0.8:8083/mypath/admin/health",
          "serviceUrl": "http://192.168.0.8:8083/",
          "source": "discovery",
          "metadata": {
            "management.context-path": "/admin",
            "startup": "-518261604",
            "management.port": "8083",
            "info.path": "/admin/info"
          }
        },
        "registered": true,
        "statusInfo": {
          "status": "UP",
          "details": {
            "hystrix": {
              "status": "UP"
            },
            "diskSpace": {
              "status": "UP",
              "details": {
                "total": 499963170816,
                "free": 366424887296,
                "threshold": 10485760
              }
            },
            "refreshScope": {
              "status": "UP"
            },
            "discoveryComposite": {
              "status": "UP",
              "details": {
                "discoveryClient": {
                  "status": "UP",
                  "details": {
                    "services": [
                      "procerssor2",
                      "spring-boot-admin-sample-eureka"
                    ]
                  }
                },
                "eureka": {
                  "description": "Remote status from Eureka server",
                  "status": "UP",
                  "details": {
                    "applications": {
                      "PROCERSSOR2": 1,
                      "SPRING-BOOT-ADMIN-SAMPLE-EUREKA": 1
                    }
                  }
                }
              }
            }
          }
        },
        "statusTimestamp": "2019-08-28T18:32:19.854Z",
        "info": {},
        "endpoints": [
          {
            "id": "health",
            "url": "http://192.168.0.8:8083/mypath/admin/health"
          }
        ],
        "buildVersion": null,
        "tags": {}
      }
    ]
  }

当我删除上下文路径时。一切都很好。请帮忙

共有1个答案

寇鸿
2023-03-14

我也有同样的问题。在我的情况下,我只将eureka.instance.metadata-map.management.context-path指向${service.servlet.context-path}/执行器

server:
  port: ${service.auth-service.port}
  servlet:
    context-path: ${service.auth-service.context-path}

eureka.instance.metadata-map.management.context-path: ${service.servlet.context-path}/actuator

因此,我认为根据您的代码,它应该类似于/admin/exactor

 类似资料:
  • 我正在为我的大学项目开发一个电子商务网站(spring MVC、Java、mySql、Hibernate)。我有各种模型,如客户,产品,订单,客户历史等。 我能够显示所有客户的详细信息(在管理页面)和所有产品供客户浏览。 但我面临的问题是,我如何展示一个客户的订单和订单历史? 我的orders表有orderId、productId、quantity和total Price。但是要显示产品名,我必须

  • 我正在搜索和尝试它2天没有成功,请帮助。 我想筛选woocommerce订单,以便根据产品属性将其他详细信息从db添加到订单详细信息页面,但我找不到适合此任务的woocommerce操作/筛选器挂钩。这里假设变量; 如果,那么我需要将自定义数据从数据库添加到订单详细信息页面。 注意:我不想添加额外的元框,而是想更改订单明细表: 将默认产品映像替换为存储在数据库和中的映像, 在产品名称下面添加包含自

  • 我正在使用一个自定义的结帐字段,在我的woocommerce商店的结帐页面上为我的客户提供一个“发送到业务地址”选项。大部分代码工作正常,但我无法显示他们是否选中了后端管理订单详细信息中的复选框。 我已经添加了一个自定义结账字段到我的WooCommerce商店,并将数据保存到订单元: 这里是我试图在管理命令部分显示这些数据的地方。我已经尽可能地关注了前面关于这方面的话题,但没有任何效果。 这个问题

  • 我已将我的spring boot应用程序配置为注册到Eureka。我有一个单独的spring boot admin(SBA)应用程序,它监视注册到Eureka的所有应用程序。 如果我的应用程序中没有设置上下文路径,一切都很好。但是如果设置了上下文路径,SBA不再显示正确的信息。从留档来看,我似乎需要更新我已经完成的Eureka的元数据属性。 我的应用程序配置如下: application.prop

  • 我通过将上下文路径设置为/myservice来运行我的springboot应用程序。这将导致附加在URL处公开的所有执行器endpoint-http://localhost:8080/myservice/actuator/,而我只想要http://localhost:8080/actuator/.有没有办法告诉springboot忽略将上下文路径附加到执行器endpoint(通过Dispatche