带有MVC

时间:2017-01-11 20:18:49

标签: java spring-mvc spring-boot spring-cloud-config

我通过添加模块依赖项和@EnableConfigServer将Spring Cloud Config服务器直接插入到我现有的Spring Boot App中。一切都按预期工作,除了我刚刚意识到配置服务器URL映射正在劫持我现有的一些API端点,因为它们共享相同的server.port

例如,我在v1/docs/index.html处有一个现有页面,现在这个页面会自动映射到org.springframework.cloud.config.server.environment.EnvironmentController#labelled

    @RequestMapping("/{name}/{profiles}/{label:.*}")
    public Environment labelled(@PathVariable String name, @PathVariable String profiles,

无论如何我想知道我可以将配置服务器分成不同的端口吗?或者为它添加一个特殊的前缀以避免URL映射冲突?或者考虑到当前的可配置性,将现有API服务器用作配置服务器只是一个坏主意?

1 个答案:

答案 0 :(得分:0)

在仔细阅读文档后找到我需要的答案:)

https://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_spring_cloud_config_server

  

要更改服务器端点的位置,您可以(可选)设置spring.cloud.config.server.prefix,例如“/ config”,用于提供前缀下的资源。前缀应该开始但不以“/”结尾。它应用于Config Server中的@RequestMappings(即Spring Boot前缀server.servletPath和server.contextPath下面)。