日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

8.Eclipse中创建Maven Web项目

發(fā)布時(shí)間:2024/9/27 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 8.Eclipse中创建Maven Web项目 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.


第一步:

創(chuàng)建maven web工程

注意下面一步:

第二步:

繼承parent

修改pom.xml文件如下

<projectxmlns="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>cn.toto.maven</groupId>

?<artifactId>web</artifactId>

?<packaging>war</packaging>

?<name>web Maven Webapp</name>

?<url>http://maven.apache.org</url>

?

? <parent>?

???<groupId>cn.toto.maven</groupId>

??? <artifactId>Parent</artifactId>

? ? <version>0.0.1-RELEASE</version>

???<relativePath>../Parent/pom.xml</relativePath>?

?</parent>

?

?<dependencies>

???<dependency>

?????<groupId>junit</groupId>

????? <artifactId>junit</artifactId>

???</dependency>

???<dependency>

?????<groupId>cn.toto.maven</groupId>

?????<artifactId>MakeFriends</artifactId>

???</dependency>

?</dependencies>

?

</project>

?

第三步:

建立測(cè)試jsp

<%@ page language="java"contentType="text/html; charset=UTF-8"

??? pageEncoding="UTF-8"%>

<%@ pageimport="cn.toto.maven.MakeFriends.*"%>

<%

??? MakeFriendsmakeFriends=new MakeFriends();

???out.println(makeFriends.makeFriends("wanglipeng"));

%>

?

第四步:

自動(dòng)部署到tomcat下面(web項(xiàng)目下的pom.xml)

<build>

???<finalName>web</finalName>

???<plugins>

?????????<plugin>

?????????????<groupId>org.codehaus.cargo</groupId>

?????????????<artifactId>cargo-maven2-plugin</artifactId>

? ???????? ??<version>1.2.3</version>

? ???????? ??<configuration>

? ???????? ??????<container>

? ???????? ??????????<containerId>tomcat7x</containerId>

?????????????????????<!下面是Tomcat在電腦上的位置à

? ???????? ??????????<home>D:/Program Files/ApacheSoftware Foundation/Tomcat 5.0</home>

? ???????? ??????</container>

? ???????? ??????<configuration>

? ???????? ??????????<type>existing</type>

? ???????? ??????????<home>D:/Program Files/ApacheSoftware Foundation/Tomcat 5.0</home>

? ???????? ??????</configuration>

? ???????? ??</configuration>

? ???????? ??<executions>?

?????????????????<execution>?

?????????????????????<id>cargo-run</id>?

?????????????????????<phase>install</phase>?

?????????????????????<goals>?

?????????????????????????<goal>run</goal>?

?????????????????????</goals>?

?????????????????</execution>?

?????????????</executions>

?????????</plugin>

?????</plugins>

? </build>

?

第五步:

模塊聚合

修改parent.pom

?

Web模塊中的完整的pox.xml如下:

<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>

? <artifactId>web</artifactId>

? <packaging>war</packaging>

?

? <name>web Maven Webapp</name>

?

?? <parent>?

????? ? <groupId>cn.toto.maven</groupId>

??? ??? <artifactId>Parent</artifactId>

? ? ????<version>0.0.1-SNAPSHOT</version>

??????? <relativePath>../Parent/pom.xml</relativePath>?

? </parent>

? <dependencies>

? <dependency>

????? <groupId>junit</groupId>

????? <artifactId>junit</artifactId>

??? </dependency>

??? <dependency>

????? <groupId>cn.toto.maven</groupId>

????? <artifactId>MakeFriends</artifactId>

??? </dependency>

</dependencies>

? <build>

??? <finalName>web</finalName>

??? <plugins>

????????? <plugin>

????????????? <groupId>org.codehaus.cargo</groupId>

????????????? <artifactId>cargo-maven2-plugin</artifactId>

? ???????? ??<version>1.2.3</version>

? ???????? ??<configuration>

? ???????? ??????<container>

? ???????? ??????????<containerId>tomcat7x</containerId>

????????????????????? <!下面是Tomcat在電腦上的位置à

? ???????? ??????????<home>D:/Program Files/Apache Software Foundation/Tomcat 5.0</home>

? ???????? ??????</container>

? ???????? ??????<configuration>

? ???????? ??????????<type>existing</type>

? ???????? ??????????<home>D:/Program Files/Apache Software Foundation/Tomcat 5.0</home>

? ???????? ??????</configuration>

? ???????? ??</configuration>

? ???????? ??<executions>?

????????????????? <execution>?

? ????????????????????<id>cargo-run</id>?

????????????????????? <phase>install</phase>?

????????????????????? <goals>?

????????????????????????? <goal>run</goal>?

????????????????????? </goals>?

????????????????? </execution>?

????????????? </executions>

????????? </plugin>

????? </plugins>

? </build>

?

</project>

注意:

?

Parent中的pom.xml如下:

<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/xsd/maven-4.0.0.xsd">

? <modelVersion>4.0.0</modelVersion>

?

? <groupId>cn.toto.maven</groupId>

? <artifactId>Parent</artifactId>

? <version>0.0.1-SNAPSHOT</version>

? <packaging>pom</packaging>

?

? <name>Parent</name>

? <url>http://maven.apache.org</url>

<modules>

? ? <module>../Hello</module>?

? ? <module>../HelloFriend</module>???

? ? <module>../MakeFriends</module>

? ? <module>../web</module>

</modules>

? <properties>

??? <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

? </properties>

?

? <dependencyManagement>

? <dependencies>

??? <dependency>

????? <groupId>junit</groupId>

????? <artifactId>junit</artifactId>

????? <version>4.9</version>

????? <scope>test</scope>

??? </dependency>

??? <dependency>

????? <groupId>cn.toto.maven</groupId>

? ? ??<artifactId>HelloFriend</artifactId>

????? <version>0.0.1-SNAPSHOT</version>

????? <scope>compile</scope>

??? </dependency>

??? <dependency>

?????????? <groupId>cn.toto.maven</groupId>

?????????? <artifactId>Hello</artifactId>

?????????? <version>0.0.1-SNAPSHOT</version>

?????????? <scope>compile</scope>

?????? </dependency>

?????? <dependency>

?????????? <groupId>cn.toto.maven</groupId>

?????????? <artifactId>MakeFriends</artifactId>

?????????? <version>0.0.1-SNAPSHOT</version>

?????????? <scope>compile</scope>

?????? </dependency>

? </dependencies>

</dependencyManagement>

<distributionManagement>

??? <repository>

??? ??? <id>releases</id>

??? ??? <name>Internal Releases</name>

??? ??? <url>http://localhost:8080/nexus-2.1.2/content/repositories/releases/</url>

??? </repository>

??? <snapshotRepository>

??? ??? <id>snapshots</id>

??? ??? <name>Internal Snapshots</name>

??? ??? <url>http://localhost:8080/nexus-2.1.2/content/repositories/snapshots/</url>

??? </snapshotRepository>

? </distributionManagement>

?

</project>

?

?

總結(jié)

以上是生活随笔為你收集整理的8.Eclipse中创建Maven Web项目的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。