【错误收集】tomcat资源访问404

发布于:2024-12-19 ⋅ 阅读:(95) ⋅ 点赞:(0)

在使用tomcat的时候,tomcat 能够正常访问,index.html也能正常访问。报错界面:

在这里插入图片描述

但是只有@WebServlet的资源无法访问,原因是:servlet的版本太高

改正后的maven:

<?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>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>demo</name>
    <packaging>war</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.target>11</maven.compiler.target>
        <maven.compiler.source>11</maven.compiler.source>
        <junit.version>5.9.1</junit.version>
    </properties>

    <dependencies>
        <!--    <dependency>-->
        <!--      <groupId>jakarta.servlet</groupId>-->
        <!--      <artifactId>jakarta.servlet-api</artifactId>-->
        <!--      <version>5.0.0</version>-->
        <!--      <scope>provided</scope>-->
        <!--    </dependency>       -->
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <!--    <dependency>-->
        <!--      <groupId>jakarta.websocket</groupId>-->
        <!--      <artifactId>jakarta.websocket-api</artifactId>-->
        <!--      <version>2.0.0</version>-->
        <!--      <scope>provided</scope>-->
        <!--    </dependency>                                        -->
        <!--    &lt;!&ndash; https://mvnrepository.com/artifact/javax.websocket/javax.websocket-api &ndash;&gt;-->
        <!--    <dependency>-->
        <!--      <groupId>javax.websocket</groupId>-->
        <!--      <artifactId>javax.websocket-api</artifactId>-->
        <!--      <version>1.1</version>-->
        <!--      <scope>provided</scope>-->
        <!--    </dependency>-->

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.2</version>
      
      </plugin>
        </plugins>
    </build>
</project>