IDEA下集成tomcat7插件将tomcat内嵌到web项目中

时间:2023-03-08 19:48:32
  1. 新建一个maven web项目

    IDEA下集成tomcat7插件将tomcat内嵌到web项目中

  2. 修改pom.xml文件

        <build>
    <plugins>
    <!-- 配置Tomcat插件:
    就是本地部署,将tomcat 内嵌到 web项目中,这样可以直接运行 webapp项目。
    跟类似spring boot 项目一样,不需要再部署到额外的tomcat,直接就可以运行了。-->
    <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <configuration>
    <!-- 不需要上下文 http://localhost:8080/xxx.jsp -->
    <path>/</path>
    <port>8080</port>
    </configuration>
    </plugin>
    </plugins>
    </build>
  3. 运行项目

    一、点击右边的Maven
    IDEA下集成tomcat7插件将tomcat内嵌到web项目中

    二、点击插件下的run,即:tomcat7:run,(右键可选择debug模式)
    IDEA下集成tomcat7插件将tomcat内嵌到web项目中

    三、待项目运行完成
    IDEA下集成tomcat7插件将tomcat内嵌到web项目中

    四、访问
    IDEA下集成tomcat7插件将tomcat内嵌到web项目中