Maven已是Java的項目管理標配,如何在JavaEE開發使用Maven調用Web應用?html
在pom.xm 加入如下xml。web
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<path>/WalletWeb</path>
<port>8088</port>
<uriEncoding>UTF-8</uriEncoding>
<url>http://localhost:8080/manager/html</url>
<server>tomcat7</server>
</configuration>
</plugin>tomcat
簡要說明一下:maven
path 是訪問應用的路徑ui
port 是tomcat 的端口號編碼
uriEncoding URL按UTF-8進行編碼,這樣就解決了中文參數亂碼。url
Server 指定tomcat名稱。spa
配置就這麼簡單,基本搞掂,下面看看如何使用。.net
若是Eclipse 安裝了Maven插件,選 擇pom.xml文件,擊右鍵——>選擇 Run As——> Maven build 。插件
若是是第一次運行,會彈出下面對話框。在Goals框加加入如下命令: tomcat:run
這樣Tomcat 插件就能夠運行。
下面介紹幾個經常使用的Goal
命令 | 描述 |
tomcat:deploy | 部署一個web war包 |
tomcat:reload | 從新加載web war包 |
tomcat:start |
啓動tomcat |
tomcat:stop |
中止tomcat |
tomcat:undeploy |
中止一個war包 |
tomcat:run | 啓動嵌入式tomcat ,並運行當前項目 |