maven工程在父工程中用tomcat7插件报错 UserController is not a Servlet

img


<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>models_code_parent</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- 聚合   -->
    <modules>
        <module>models_code_dao</module>
        <module>models_code_service</module>
        <module>models_code_controller</module>
    </modules>

    <packaging>pom</packaging>

    <dependencyManagement>

        <dependencies>
            <!--   代码测试     -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.13.2</version>
            </dependency>

            <!--     servlet-api       -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>4.0.1</version>
            </dependency>

            <!--     javax.servlet.jsp       -->
            <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>javax.servlet.jsp-api</artifactId>
                <version>2.3.3</version>
            </dependency>

            <!--     thymeleaf模板引擎       -->
            <dependency>
                <groupId>org.thymeleaf</groupId>
                <artifactId>thymeleaf</artifactId>
                <version>3.0.12.RELEASE</version>
            </dependency>

            <!-- dbutil工具类 -->
            <dependency>
                <groupId>commons-dbutils</groupId>
                <artifactId>commons-dbutils</artifactId>
                <version>1.7</version>
            </dependency>

            <!-- 德鲁伊连接池 -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>1.2.8</version>
            </dependency>

            <!-- mysql驱动 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.26</version>
            </dependency>

            <!-- lombok -->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.22</version>
            </dependency>
        </dependencies>

    </dependencyManagement>

    <build>
        <plugins>
            <!-- jdk编译版本插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>


            <!-- 配置Tomcat插件 ,用于启动项目 -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <!--如果不设置,则默认为猫的自定义端口,项目路径为http://localhost:默认端口/项目名  -->
                <configuration>
                    <!--如果端口号改为8088:那么访问的时候路径的端口就要写成8088  -->
                    <port>8080</port>
                    <!-- 如果设置为/,则项目了路径为http://localhost:端口号 /-->
                    <!-- 如果设置为/lw,则项目了路径为http://localhost:端口号/lw -->
                    <path>/</path>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

用idea的tomcat又能正常访问

跟这没关系,你那报错说的很清楚,UserController is not a Servlet,你配置对不对