• 在Idea中通过Tomcat运行maven项目


    转:

    在Idea中通过Tomcat运行maven项目

    1.在Idea中通过Tomcat的Maven插件运行项目
    (1)Tomcat 7的配置(推荐,下载速度较快)

    在pom.xml中加入下面红色字体部分的配置:

        <build>
          <finalName>项目名称</finalName>
          <pluginManagement>
         
        省略…
          </pluginManagement>
          <plugins>
                <plugin>
                  <groupId>org.apache.tomcat.maven</groupId>
                  <artifactId>tomcat7-maven-plugin</artifactId>
                  <version>2.2</version>
                  <configuration>
                      <port>8000</port>
                      <path>/test</path>
                      <uriEncoding>UTF-8</uriEncoding>
                      <server>tomcat7</server>
                  </configuration>
               </plugin>
           </plugins>
        </build>

    (2)Tomcat 8的配置(不推荐,非官方仓库,下载速度很慢)

    在pom.xml中加入下面红色字体部分的配置:

        <pluginRepositories>
        <pluginRepository>
            <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
        </pluginRepository>
        <pluginRepository>
            <id>alfresco-public-snapshots</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>beardedgeeks-releases</id>
            <url>http://beardedgeeks.googlecode.com/svn/repository/releases</url>
        </pluginRepository>
        </pluginRepositories>
         
        <build>
          <finalName>项目名称</finalName>
          <pluginManagement>
         
        省略…
         
          </pluginManagement>
         
          <plugins>
         
                <plugin>
         
                  <groupId>org.apache.tomcat.maven</groupId>
         
                  <artifactId>tomcat8-maven-plugin</artifactId>
         
                  <version>3.0-r1655215</version>
         
                  <configuration>
         
                      <port>8000</port>
         
                      <path>/test</path>
         
                      <uriEncoding>UTF-8</uriEncoding>
         
                      <server>tomcat7</server>
         
                  </configuration>
         
               </plugin>
         
           </plugins>
         
        </build>

    (3)检查配置是否成功

    (4)运行项目

    出现以下提示信息:

    [INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ MavenSpringHelloWorld

    [INFO] Running war on http://localhost:8000/test

    [INFO] Using existing Tomcat server configuration at E:IdeaWorkSpaceMavenSpringHelloWorld arget omcat

    [INFO] create webapp with contextPath: /test

     

    在浏览器中输入url,即可成功运行。

    2.在Idea中使用外置的Tomcat运行项目
    (1)通过Run->Edit Configurations…进入配置界面

     

     

     


    (2)在Tomcat Server中的Local配置Tomcat

    然后再点OK,就配好了。
    ————————————————
    版权声明:本文为CSDN博主「zc15779595171」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/zc15779595171/java/article/details/83098052

  • 相关阅读:
    如何给发票抬头增加页签
    记录激活SAP SMTP服务过程
    反射
    乱码问题
    使用idea的常用的技巧
    解决double的值相加的问题
    代理模式之静态代理
    foreach的真面目
    记录java的面试的每一个瞬间
    变量的经典
  • 原文地址:https://www.cnblogs.com/libin6505/p/13255745.html
Copyright © 2020-2023  润新知