IntelliJ IDEA配置Tomcat/Jetty運行Web項目

1、使用Maven的POM引入插件的形式:html

這種方式只需在POM中引入Tomcat/Jetty的插件便可運行。參考:http://www.cnblogs.com/EasonJim/p/6687272.htmlweb

POM:apache

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.jsoft.test</groupId>
    <artifactId>testweb</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>testweb Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>testweb</finalName>
        <plugins>
            <!-- Config: Maven Tomcat Plugin --> <!-- http://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat7-maven-plugin --> <!-- http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/plugin-info.html --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <!-- Config: contextPath and Port (Default:8080) --> <!-- <configuration> <path>/</path> <port>8899</port> </configuration> --> </plugin> <!-- Config: Maven Jetty Plugin --> <!-- http://mvnrepository.com/artifact/org.mortbay.jetty/jetty-maven-plugin --> <!-- http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html --> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.4.3.v20170317</version> <!-- Config: contextPath and Port (Default:8080) --> <!-- <configuration> <httpConnector> <port>8899</port> </httpConnector> <webAppConfig> <contextPath>/</contextPath> </webAppConfig> </configuration> --> </plugin>
        </plugins>
    </build>
</project>

運行:tomcat

【View】->【Tool Windows】->【Maven Projects】app

而後選擇列表的jetty:run,右鍵Run Maven Build。或者tomcat:run。eclipse

這些插件還有不少用法,要深刻使用能夠右鍵Edit...研究下去。maven

2、經過自帶的的Tomcat插件運行:ui

前提:先安裝好Tomcat,參考:(搜索本博客Tomcat安裝)url

配置:【Run】->【Edit Configurations】spa

配置好本地的Tomcat,指向安裝的路徑:

接下來點擊左上角的加號:【Tomcat Server】->【Local】

有兩種選擇,能夠是war包或者指定編譯後的target文件夾:

一、war包:

二、target文件夾

最後就是運行:【Run】->【Run ...】,而後選擇上面建立的TestWeb便可。

3、經過自帶的Jetty插件:

原理和上面的基本同樣:

一、配置Jetty本地Local

二、添加Jetty

三、Run

 

 

參考:

http://www.javashuo.com/article/p-keacwcbd-ec.html

相關文章
相關標籤/搜索