Spring Boot trouble by deployment on Tomcat Server 8.5

338 Views Asked by At

i have troubles by deployment my Spring Boot Project on Tomcat Server 8.5. This project work fine in Eclipse on local Tomcat but after deployment on global Tomcat Server i see error 404 enter image description here

if i write the source path like absolut path-> <body background="./images/brickwall.png"> than is all ok. this is my pom-

<?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>
    
    <groupId>cth</groupId>
    <artifactId>aaaaa</artifactId>
    <version>0.0.1</version>
    <packaging>war</packaging>
    <name>bbbb</name>
    <description> Spring Boot Projekt</description>     
    <parent>
            <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.7</version>
    <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>12</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>
        <!-- Security -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build> 
</project>
1

There are 1 best solutions below

2
Kashan Nadeem On

Make sure you don't have set the property server.servlet.contextPath, as this is for embedded Tomcat only. It is not needed if you are deploying the application to another Tomcat.