I have been testing Spring Boot with embedded Tomcat for about a month now to build a REST API. Everything was working fine. We now want to deploy the API in a separate deve
check java -version means the if you complied war in java 8 and tomcat is running on java 7 then it doesn't work.
When running an application the path to call consists of a couple of parts.
The first is the base URL on which the application is deployed, in your case that is /sophia
.
The second is the servlet mapping of the DispatcherServlet
in your case that is /sohpia/*
.
The third is the mapping of the controller inside the DispatcherServlet
, in your example that is /users
.
All those things combined create the URL /sophia/sophia/users
.
The difference between the deployment as a WAR is that you included a separate URL to deploy on, when running as a jar it, by default, is deployed to /
(the root).
You could fix it by putting /sophia
as the server.context-path
in the application.properties
and map the DispatcherServlet
to /*
or /
. That will in both situations give you the URL you want (and expected).
Have you tried extending the SpringBootServletInitializer and overriding the configure method? As stated here
The entry point for jar file is different [Main Class] when compared to running your app as war file inside a container.
Hope this helps.