首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Cloud Gateway背后的Camunda没有返回驾驶舱的CSS文件

Spring Cloud Gateway背后的Camunda没有返回驾驶舱的CSS文件
EN

Stack Overflow用户
提问于 2020-09-25 23:53:34
回答 1查看 179关注 0票数 0

我有一个嵌入在Spring Boot应用程序中的Camunda实例(称为服务工作流),它在动态端口上启动,并通过Eureka注册到Spring Cloud。

Camunda服务的主类很简单:

代码语言:javascript
复制
@EnableDiscoveryClient
@SpringBootApplication
@EnableConfigurationProperties(ServiceContextConfig.class)
public class WorkflowServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(WorkflowServiceApplication.class, args);
    }
}

和配置属性:

代码语言:javascript
复制
server.port=0
eureka.client.healthcheck.enabled=true

这些服务位于本地Spring Cloud Gateway后面,该网关在使用尤里卡注册主机的端口上运行,并且可以通过http://localhost:8080访问和路由

网关的代码为:

代码语言:javascript
复制
@SpringBootApplication
@EnableDiscoveryClient
public class GatewayServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(GatewayServiceApplication.class, args);
    }
}

和配置属性:

代码语言:javascript
复制
server.port=8080
spring.cloud.gateway.discovery.locator.enabled=true
spring.cloud.gateway.discovery.locator.lowerCaseServiceId=true

没有定义路由-它完全依赖于Eureka来查找路由。这对于REST连接来说是没有问题的。

任何使用runtimeService的客户端都可以使用带有URL: feign.client.config.remoteRuntimeService.url=service-workflow/rest/的feign启动工作流

因此,可以通过REST API的网关URL访问工作流服务。

当Camunda服务启动,并获得分配的端口x时,我可以通过http://localhost:x/app/cockpit/default/查看驾驶舱。但是,如果我尝试通过网关,即http://localhost:8080/service-workflow/app/cockpit/default/,它无法返回任何CSS文件-网关日志显示:

代码语言:javascript
复制
2020-09-25 16:46:00,454 DEBUG [reactor-http-nio-2] reactor.netty.http.server.HttpServer (Loggers.java:254) - [id: 0xe08516d1, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:61018] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@74cedfb5
2020-09-25 16:46:00,453 DEBUG [reactor-http-nio-8] org.springframework.web.server.adapter.HttpWebHandlerAdapter (LogFormatUtils.java:91) - [9407161c-27] HTTP GET "/app/cockpit/styles/styles.css?bust=7.12.0"
2020-09-25 16:46:00,456 DEBUG [reactor-http-nio-2] org.springframework.web.server.adapter.HttpWebHandlerAdapter (LogFormatUtils.java:91) - [e08516d1-28] HTTP GET "/app/cockpit/styles/user-styles.css?bust=7.12.0"
2020-09-25 16:46:00,455 DEBUG [reactor-http-nio-7] reactor.netty.http.server.HttpServer (Loggers.java:254) - [id: 0x125a09dc, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:61253] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@74cedfb5
2020-09-25 16:46:00,458 DEBUG [reactor-http-nio-8] org.springframework.web.reactive.handler.SimpleUrlHandlerMapping (AbstractHandlerMapping.java:183) - [9407161c-27] Mapped to ResourceWebHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"]
2020-09-25 16:46:00,460 DEBUG [reactor-http-nio-7] org.springframework.web.server.adapter.HttpWebHandlerAdapter (LogFormatUtils.java:91) - [125a09dc-29] HTTP GET "/app/cockpit/styles/styles-components.css?bust=7.12.0"
2020-09-25 16:46:00,460 DEBUG [reactor-http-nio-2] org.springframework.web.reactive.handler.SimpleUrlHandlerMapping (AbstractHandlerMapping.java:183) - [e08516d1-28] Mapped to ResourceWebHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"]
2020-09-25 16:46:00,463 DEBUG [reactor-http-nio-8] org.springframework.web.reactive.resource.ResourceWebHandler (ResourceWebHandler.java:324) - [9407161c-27] Resource not found
2020-09-25 16:46:00,464 DEBUG [reactor-http-nio-7] org.springframework.web.reactive.handler.SimpleUrlHandlerMapping (AbstractHandlerMapping.java:183) - [125a09dc-29] Mapped to ResourceWebHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"]
2020-09-25 16:46:00,465 DEBUG [reactor-http-nio-2] org.springframework.web.reactive.resource.ResourceWebHandler (ResourceWebHandler.java:324) - [e08516d1-28] Resource not found
2020-09-25 16:46:00,466 DEBUG [reactor-http-nio-7] org.springframework.web.reactive.resource.ResourceWebHandler (ResourceWebHandler.java:324) - [125a09dc-29] Resource not found
2020-09-25 16:46:00,469 DEBUG [reactor-http-nio-2] org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler (CompositeLog.java:147) - [e08516d1-28] Resolved [ResponseStatusException: 404 NOT_FOUND] for HTTP GET /app/cockpit/styles/user-styles.css
2020-09-25 16:46:00,468 DEBUG [reactor-http-nio-8] org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler (CompositeLog.java:147) - [9407161c-27] Resolved [ResponseStatusException: 404 NOT_FOUND] for HTTP GET /app/cockpit/styles/styles.css
2020-09-25 16:46:00,476 DEBUG [reactor-http-nio-2] org.springframework.core.codec.CharSequenceEncoder (CompositeLog.java:147) - [e08516d1-28] Writing "<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you  (truncated)...
2020-09-25 16:46:00,479 DEBUG [reactor-http-nio-7] org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler (CompositeLog.java:147) - [125a09dc-29] Resolved [ResponseStatusException: 404 NOT_FOUND] for HTTP GET /app/cockpit/styles/styles-components.css
2020-09-25 16:46:00,477 DEBUG [reactor-http-nio-8] org.springframework.core.codec.CharSequenceEncoder (CompositeLog.java:147) - [9407161c-27] Writing "<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you  (truncated)...
2020-09-25 16:46:00,480 DEBUG [reactor-http-nio-7] org.springframework.core.codec.CharSequenceEncoder (CompositeLog.java:147) - [125a09dc-29] Writing "<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you  (truncated)...
2020-09-25 16:46:00,480 DEBUG [reactor-http-nio-2] reactor.netty.http.server.HttpServerOperations (Loggers.java:254) - [id: 0xe08516d1, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:61018] Decreasing pending responses, now 0
EN

回答 1

Stack Overflow用户

发布于 2021-04-26 16:48:49

我最终解决这个问题的方法是在网关中添加一个自定义路由:

代码语言:javascript
复制
.route("camunda", r -> r.path("/camunda/**")
        //.filters(f -> f.rewritePath("/report/(?<segment>.*)", "/${segment}"))
        .uri("lb://my-camunda-service"))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64067471

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档