最新maven項目 tomcat熱部署

maven 項目搭建網上一搜一大篇,我知道maven-project項目可以直接生成web項目,新手別創建錯了,不要選擇quickstart,要選擇webapp(maven-archetype-webapp)

簡要說明webapp的創建主要還是介紹熱部署

maven項目創建步驟,使用的eclipse

 右鍵new-->other-->Maven Project-->next-->next-->選擇maven-archetype-webapp-->next

  說明:GroupId 隨便輸入 比如com.maven  atifact id 隨便輸入 比如demo 然後finish就完成了一個maven web項目的創建

  如果有初學者實在不懂,給我評論,我搞個最新最詳細有解釋的給你


進入正題


1.默認項目創建完成的POM.xml ,加入了支持tomcat需要的配置

<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.maven</groupId>
	<artifactId>demo</artifactId>
	<packaging>war</packaging>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo 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>demo</finalName>
	<!-- 以下內容是新加入   主要是tomcat的支持  -->
	<!-- 以前的tomcat-maven-plugin apache好像已經不支持了 必須加tomcat6或7 -->
		<plugins>
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.0</version>
				<configuration>
					<url>http://localhost:8080/manager/html</url>
					<server>tomcat</server>
				</configuration>
			</plugin>
		</plugins>
	<!-- 新加內容結束 -->
	</build>
</project>

2.配置


3.熱部署完成,等待maven下載tomcat插件相關信息,瀏覽器輸入localhost:8080/demo/index.jsp  --->hello word-->大功告成

創建的是maven-webapp項目,創建完成之後除了上面我說的,其他都可以不用做,就可以完成hello word的輸出

發佈了13 篇原創文章 · 獲贊 1 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章