Spring Boot application runs normally on embedded Tomcat server when I run it from Eclipse, but when I deploy it to external tomcat server (on Windows) I'm getting HTTP 404 status.
I did clean package and copied from target folder war file in tomcat webapps folder on local tomcat server and I restarted tomcat but...
When I run get method in postman with endpoint http://localhost:8080/export/test/ I get 404 not found
Tomcat version 9
Java 11
TOMCAT MANAGER:
@SpringBootApplication
public class ExportApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(ExportApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(ExportApplication.class);
}
}
POM file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>bojankosta</groupId>
<artifactId>export</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>export</name>
<description>Export db</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.properties:
server.servlet.context-path=/export
Controller:
package bojankosta.export.controller;
import bojankosta.export.service.ContinentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class BasicController {
@Autowired
private ContinentService continentService;
@GetMapping("/")
public String getAllData() {
return continentService.export();
}
@GetMapping("/test")
@ResponseBody
public String currentUserName() {
return "Hello";
}
}
