After Deploying War File In Tomcat Api Not Working

- 1 answer

I'm trying to deploy app in my local tomcat but have some problems. I use: Tomcat 9, Spring boot, ReactJS and Webpack. When I run embedded Tomcat (in Eclipse) all be ok - API working good, but when I build war file and paste it to my local Tomcat - API not working, all request failed.

enter image description here

How I build war file:

How I can change this path?

server.port = 8080
management.server.port: 8995

@RequestMapping(value = "/api/originator", method = RequestMethod.GET)
public List<OriginatorModel> retrieveOriginators() {"Performing /api/originator GET request");
    return originatorService.retrieveOriginators();

My pom.xml:




When you start the application from Eclipse, it uses a standalone server, which is directly accessed via localhost and the URL is http://localhost:8080/api/originator.

When you run your local tomcat instance, http://localhost:8080 is the base tomcat URL. What follows next is the name of your application, in this case web_importer. So the URL becomes http://localhost:8080/web_importer/api/originator and this is why you get 404 Not Found.

It seems that your frontend is calling the API directly at http://localhost:8080/api/originator. You need to change your base API URL in your frontend configuration when you want to use the tomcat-deployed version of your API.