带有api网关的spring boot war部署URL

时间:2018-05-14 10:13:30

标签: spring spring-boot url netflix-zuul netflix-eureka

我使用的是春季启动版1.5.10.RELEASE。 我使用spring boot开发了服务,并使用了Eureka服务寄存器Zuul API Gateway。 我的应用程序pom文件应用程序名称是" TestApplication"

<build>
    <finalName>TestApplication</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

tomcat部署的战争名称是&#34; testservice.war&#34;。

因此,当我使用API​​ Gateway访问应用程序的URL时,它就像下面那样形成

http://localhost:8080/ApiGateway/testapplication/testservice/swagger-ui.html

格式:zuul api gateway context / applicationname / contextname

我想在网址中避免使用上下文名称(testservice),并使用eureka注册名称进行访问,如下所示:

http://localhost:8080/ApiGateway/testservice/swagger-ui.html

1 个答案:

答案 0 :(得分:0)

您可以添加到Zuul .properties文件的路线,例如:

zuul.routes.testapplication.path=/testapplication
zuul.routes.testapplication.service-id=testapplication

然后你可以这样打电话给你:http://APIGATEWAY:8080/testapplication/swagger-ui.html/