【问题标题】:Error init SpringBoot 2.1.8.RELEASE using actuator使用执行器初始化 SpringBoot 2.1.8.RELEASE 时出错
【发布时间】:2020-01-30 12:01:53
【问题描述】:

我有一个 SpringBoot 2.1.8.RELEASE,但是当我启动应用程序时。我收到了这个错误:

2019-10-01 10:38:24.373 ERROR 16232 --- [           main] d.c.b.a.s.c.d.InstanceDiscoveryListener  : Couldn't register instance for discovered instance...
    java.lang.IllegalArgumentException: Illegal character in authority at index 7: http://127.0.0.1:2222${server.contextPath}/actuator/health
        at java.net.URI.create(URI.java:852)
        at de.codecentric.boot.admin.server.cloud.discovery.EurekaServiceInstanceConverter.getHealthUrl(EurekaServiceInstanceConverter.java:45)

我在我的 yml 文件中定义了这个属性

server:
  port: 2222
  servlet:
    contextPath:

【问题讨论】:

  • 检查空格。当 yaml 格式/空格不正确时会出现此错误
  • 但应该抱怨 ${server.servlet.contextPath},而不是 ${server.contextPath}
  • 你的 eureka 服务 url 在你的配置中是什么样子的?

标签: spring-boot yaml spring-cloud netflix-eureka spring-boot-actuator


【解决方案1】:

只需删除

 servlet:
     contextPath:

并尝试使用您的 API。

如果你想要应用程序的默认路径,那么

servlet:
 contextPath: /api

那么你的 API 看起来像:

http://127.0.0.1:2222/api/actuator/health

【讨论】:

  • 结果相同
【解决方案2】:

如下更改yml文件并尝试:

server:
  port: 2222
  servlet.context-path: /

【讨论】:

  • 结果相同
猜你喜欢
  • 1970-01-01
  • 2017-10-21
  • 1970-01-01
  • 2023-03-23
  • 2022-01-04
  • 1970-01-01
  • 2021-06-09
  • 1970-01-01
  • 2019-11-01
相关资源
最近更新 更多