【问题标题】:spring cloud gateway exception Illegal character in authority at index errorspring cloud gateway exception Illegal character in authority at index error
【发布时间】:2019-06-06 15:13:22
【问题描述】:

我正在尝试为 api 设置 spring 云网关,但看到路由 uri 存在非法参数异常。任何帮助表示赞赏。

在 Ubuntu 上运行这个应用程序,我在 Spring boot 2.1.4 和 2.1.5 中都遇到了同样的异常。

这是在网关应用程序中配置我的 application.properties 文件的方式。

eureka.client.serviceUrl.defaultZone = http://localhost:8761/eureka
spring.application.name= api-gateway
spring.cloud.gateway.discovery.locator.enabled=true
spring.cloud.gateway.discovery.locator.lowerCaseServiceId=true
spring.cloud.gateway.routes[0].id=reporting-service
spring.cloud.gateway.routes[0].uri = lb://reporting-service
spring.cloud.gateway.routes[0].predicates[0]=Path=/api/reporting/**

这是我看到的例外。

2019-06-06 09:56:17.304  WARN 4561 --- [           main] onfigReactiveWebServerApplicationContext : Exception encountered during context initializ                                                ation - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration';                                                 nested exception is reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Illegal character in authority at in                                                dex 5: lb://REPORTING-SERVICE
2019-06-06 09:56:17.316  INFO 4561 --- [           main] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
2019-06-06 09:56:20.317  INFO 4561 --- [           main] com.netflix.discovery.DiscoveryClient    : Unregistering ...
2019-06-06 09:56:20.324  INFO 4561 --- [           main] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_API-GATEWAY/apitest.****.*****.com:api-gateway:8080 - deregister  status: 200
2019-06-06 09:56:20.342  INFO 4561 --- [           main] com.netflix.discovery.DiscoveryClient    : Completed shut down of DiscoveryClient
2019-06-06 09:56:20.353  INFO 4561 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-06 09:56:20.365 ERROR 4561 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is reactor.core.Ex                                                ceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Illegal character in authority at index 5: lb://REPORTING-SERVICE
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.1.6.RELEAS                                                E.jar!/:5.1.6.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.1.6.RELE                                                ASE.jar!/:5.1.6.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context                                                -5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.1.6.REL                                                EASE.jar!/:5.1.6.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.1.6.RELE                                                ASE.jar!/:5.1.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:893) ~[spring-context-5.1.                                                6.RELEASE.jar!/:5.1.6.RELEASE]
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.finishRefresh(ReactiveWebServerApplicationContext.jav                                                a:121) ~[spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.6.RELE                                                ASE.jar!/:5.1.6.RELEASE]
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:67)                                                 ~[spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]

【问题讨论】:

  • 这就是问题
  • 感谢您的帮助,但在进行更改后,我的构建失败并出现此错误。应用程序启动失败说明:绑定到目标 [Bindable@330c1f61 type = java.util.List, value = 'provided', annotations = array[@ javax.validation.constraints.NotEmpty(message={javax.validation.constraints.NotEmpty.message}, groups=[], payload=[]), @javax.validation.Valid()]] 失败:属性:spring.cloud .gateway.routes[0].predicates[0].path 值:/api/reporting/**
  • 这是我在错误消息中看到的。原因:org.springframework.boot.context.properties.bind.BindException:无法将 'spring.cloud.gateway.routes[0].predicates' 下的属性绑定到 java.util.List 原因:org.springframework.boot.context.properties.bind.UnboundConfigurationPropertiesException:元素 [spring.cloud.gateway.routes[0].predicates[0].path] 未绑定。
  • 我错了,改成这个spring.cloud.gateway.routes[0].predicates=Path=/api/reporting/**

标签: spring spring-boot spring-cloud netflix-eureka spring-cloud-gateway


【解决方案1】:

修复属性:

spring.cloud.gateway.routes[0].predicates=Path=/api/reporting/**

spring.cloud.gateway.routes[0].uri=lb://reporting-service

参考:issue-56480485

【讨论】:

  • 我仍然遇到同样的错误。 org.springframework.context.ApplicationContextException:无法启动 bean 'eurekaAutoServiceRegistration';嵌套异常是 reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Illegal character in authority at index 5: lb://REPORTING-SERVICE
  • 删除不需要的空格并尝试spring.cloud.gateway.routes[0].uri=lb://reporting-service
  • 删除了空格,但没有帮助
  • 我需要设置一些负载均衡器才能正常工作吗?
  • @Sam 我没有看到任何问题,我能够成功加载。看看这里issue-56480485
猜你喜欢
  • 2016-08-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-04
  • 1970-01-01
  • 1970-01-01
  • 2020-06-26
  • 2021-06-27
相关资源
最近更新 更多