1

If I run my project with Tomcat a valid REST call would look like this:

http://localhost:8080/rest-api/dl4j/we/getModelInfo?modelName=123

However, if I start it from within a Java main method with @SpringBootApplication I have to call

http://localhost:8080/api/dl4j/we/getModelInfo?modelName=123

How can I ensure that this path stays the same for all REST controller?

This is how I run the server programmatically:

public static void main(String[] args) {

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {         
        LOGGER.info("EasyModelAccessServer Server is shutting down.");}
    ));

    SpringApplication.run(EasyModelAccessServer.class, args);
}
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
  • 1
    what have you set for your server.contextPath ? have a look at [this](http://stackoverflow.com/questions/24452072/how-do-i-choose-the-url-for-my-spring-boot-webapp) – Sasi Kathimanda Feb 05 '17 at 12:49
  • 1
    @SasiKathimanda Interesting - it seems like Spring never used my application.properties because there it actually says `api/` - The question then would be why it ignored that as I started the server directly with Tomcat from within Eclipse O_o – Stefan Falk Feb 05 '17 at 12:54

1 Answers1

1

The context path is determined by the servlet container. For example, Tomcat used the file name of the war copied into the web apps directory. In a external WAR deployment, with Tomcat server.xml configured with a connector, you cannot specify this in the application configuration (application.yml or application.properties).

Sasi Kathimanda
  • 1,788
  • 3
  • 25
  • 47