简体   繁体   中英

spring boot war deployment url with api gateway

I am using spring boot version 1.5.10.RELEASE. I have developed on service using spring boot and used Eureka service register, Zuul API Gateway. My applications pom file application name is "TestApplication"

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

And tomcat deployed war name is "testservice.war".

So when I access the URL of application using API Gateway it is formed like below

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

format: zuul api gateway context/ applicationname/contextname

I want to avoid context name (testservice) in the url and access with eureka registered name only like below:

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

You can add a route to Zuul .properties file, something like :

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

Then you can call your service like this : http://APIGATEWAY:8080/testapplication/swagger-ui.html/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM