首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

Maven2学习札记二

2012-07-03 
Maven2学习笔记二原文:http://topcat.iteye.com/blog/3102476.创建这个简单的Web应用 mvn?archetype:creat

Maven2学习笔记二

原文:http://topcat.iteye.com/blog/310247

6.创建这个简单的Web应用

mvn?archetype:create?-DgroupId=org.sonatype.mavenbook.ch05?-DartifactId=simple-webapp?-DpackageName=org.sonatype.mavenbook?-DarchetypeArtifactId=maven-archetype-webapp

?

·?配置jetty插件

<build>

????<finalName>simple-webapp</finalName>

????<plugins>

??????<plugin>

????????<groupId>org.mortbay.jetty</groupId>

????????<artifactId>maven-jetty-plugin</artifactId>

??????</plugin>

????</plugins>

??</build>

?

mvn?jetty:run

启动jetty

当?Maven?启动了?Jetty?Servlet?容器之后,在浏览器中载入?URL?http://localhost:8080/simple-webapp/

7.多模块项目

在父文件夹的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/maven-v4_0_0.xsd">

??<modelVersion>4.0.0</modelVersion>

<!--这里定义了父pom的坐标-->

??<groupId>org.sonatype.mavenbook.ch06</groupId>

??<artifactId>simple-parent</artifactId>

??<packaging>pom</packaging>

??<version>1.0</version>

??<name>Chapter?6?Simple?Parent?Project</name>

?<!--这里定义了它的子模块有哪些-->

??<modules>

????<module>simple-weather</module>

????<module>simple-webapp</module>

??</modules>

<!--下面的部分是可以被子模块继承的-->

??<build>

????<pluginManagement>

??????<plugins>

????????<plugin>

??????????<groupId>org.apache.maven.plugins</groupId>

??????????<artifactId>maven-compiler-plugin</artifactId>

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

????????????<source>1.5</source>

????????????<target>1.5</target>

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

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

??????</plugins>

???</pluginManagement>?

??</build>

?

??<dependencies>

????<dependency>

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

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

??????<version>3.8.1</version>

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

????</dependency>

??</dependencies>

</project>

在子模块中的pom.xml文件里在最上方增加了:

<!--父的坐标-->

<parent>

????<groupId>org.sonatype.mavenbook.ch06</groupId>

????<artifactId>simple-parent</artifactId>

????<version>1.0</version>

??</parent>

这样就成了一个双向的关系

基本的使用就这样了,关于插件的使用可以去

http://maven.apache.org/plugins/index.html??查看

热点排行