Spring Cloud Gateway异常索引错误的权限中的非法字符

时间:2019-06-06 15:13:22

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

我正在尝试为API设置Spring Cloud Gateway,但是看到路线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]

1 个答案:

答案 0 :(得分:0)

修复属性:

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

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

参考:issue-56480485