春季启动问题-java.lang.IllegalArgumentException:值只能包含有效字符

时间:2019-02-05 11:24:14

标签: java spring-boot spring-cloud

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

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)

3 个答案:

答案 0 :(得分:2)

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

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

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

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

答案 1 :(得分:0)

经过一段时间的调查,看来我应该使用其他版本的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 :(得分:0)

对我来说也遇到同样的问题。我的原因是在 application.yml 文件中,我将 / 符号用于 端点enter image description here

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