【问题标题】:Spring startup issue - java.lang.IllegalArgumentException: Value must only contain valid charsSpring 启动问题 - java.lang.IllegalArgumentException:值只能包含有效字符
【发布时间】:2019-06-29 05:00:27
【问题描述】:

在 Spring Boot(2.0.6.RELEASE) 项目中添加 Spring Cloud(Finchley.M8) 依赖后,出现异常:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is java.lang.IllegalArgumentException: Value must only contain valid chars
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)
    ... 23 common frames omitted
Caused by: java.lang.IllegalArgumentException: Value must only contain valid chars
    at org.springframework.util.Assert.isTrue(Assert.java:116)
    at org.springframework.boot.actuate.endpoint.EndpointId.<init>(EndpointId.java:44)
    at org.springframework.boot.actuate.endpoint.EndpointId.of(EndpointId.java:102)
    at org.springframework.boot.actuate.endpoint.annotation.EndpointDiscoverer$EndpointBean.<init>(EndpointDiscoverer.java:471)

【问题讨论】:

  • 就我而言,使用management.endpoints.web.exposure.include=* 而不是management.endpoints.web.exposure.include="*"

标签: java spring-boot spring-cloud


【解决方案1】:

经过一段时间的调查,看来我应该使用不同版本的 Spring Cloud。

我从 Finchley.M8 更改为 Finchley.SR2,一切正常。

Spring Cloud + Spring Boot 2.0.x 兼容性说明: https://github.com/spring-projects/spring-cloud/wiki/spring-cloud-finchley-release-notes

【讨论】:

  • 是的,通常你应该使用发布版本而不是里程碑
【解决方案2】:

对我来说也遇到同样的问题。我的原因是在 application.yml 文件中我使用 / 符号表示 endpoint.

management:
  endpoints:
    web:
      exposure:
        include: hystrix.stream

【讨论】:

    【解决方案3】:

    我在启动 springCloudConfigServer 项目时遇到了同样的异常。

    根本原因是 application.properties 中以下属性的值不正确(错字)

    之前: management.endpoints.web.exposure.include=bus=refresh

    我像下面这样更改它,我的项目成功启动 management.endpoints.web.exposure.include=总线刷新

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-22
      • 2020-09-19
      • 1970-01-01
      • 2011-03-13
      • 1970-01-01
      • 1970-01-01
      • 2021-11-21
      • 1970-01-01
      相关资源
      最近更新 更多