Maven3实战笔记12Maven构建Web应用
<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>MavenAccount-web</groupId><artifactId>MavenAccount-web</artifactId><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><name>MavenAccount-web</name><url>http://maven.apache.org</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><scope>test</scope></dependency></dependencies></project>
?之后就是放置web文件的位置,Maven约定web文件放到src/main/webapp下面,用过MyEclipse的朋友们可能知道,开发web项目根目录下除了有src目录,都有一个叫做WebRoot的目录用于存储web资源的。
?webapp下面就是那个放置页面资源的文件夹。
package MavenAccountweb;/** * Hello world! */public class App {public String sayWebHello(String str) {System.out.println(str);return "hello:" + str;}}
<%@ page language="java" import="MavenAccountweb.App"pageEncoding="utf-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Hello Web</title><!--<link rel="stylesheet" type="text/css" href="styles.css">--></head><body><%App app = new App();String newString = app.sayWebHello("liuyan");%>[<%=newString%>]<br></body></html>
mvn clean package
?其中MavenAccount-web-0.0.1-SNAPSHOT.war,我们将其部署到本机的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/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.starit.resource</groupId><artifactId>resource-parent</artifactId><version>1.0.0-SNAPSHOT</version></parent><packaging>war</packaging><artifactId>ts.ires.web</artifactId><name>starit resource web</name><dependencies> <dependency><groupId>com.starit.resource</groupId><artifactId>ts.ires.core</artifactId><version>${parent.version}</version></dependency><dependency><groupId>com.starit.resource</groupId><artifactId>ts.ires.admin</artifactId><version>${parent.version}</version></dependency><dependency><groupId>com.starit.resource</groupId><artifactId>ts.ires.application</artifactId><version>${parent.version}</version></dependency><dependency><groupId>com.starit.resource</groupId><artifactId>ts.ires.collection</artifactId><version>${parent.version}</version></dependency><dependency><groupId>com.starit.resource</groupId><artifactId>ts.ires.metadata</artifactId><version>${parent.version}</version></dependency><dependency><groupId>com.starit.resource</groupId><artifactId>ts.ires.monitor</artifactId><version>${parent.version}</version></dependency><dependency><groupId>com.starit.resource</groupId><artifactId>ts.ires.service</artifactId><version>${parent.version}</version></dependency><dependency><groupId>com.starit.resource</groupId><artifactId>ts.ires.share</artifactId><version>${parent.version}</version></dependency></dependencies><build><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>tomcat-maven-plugin</artifactId><configuration><server>myserver</server><path>/resource</path></configuration></plugin><plugin><groupId>org.mortbay.jetty</groupId><artifactId>jetty-maven-plugin</artifactId><version>7.2.2.v20101205</version><configuration><webAppConfig><contextPath>/resource</contextPath></webAppConfig><!--<scanIntervalSeconds>3</scanIntervalSeconds>--><connectors><connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"><port>8080</port><maxIdleTime>30000</maxIdleTime></connector></connectors><webAppSourceDirectory>src/main/webapp</webAppSourceDirectory></configuration></plugin></plugins></build></project> 2 楼 suhuanzheng7784877 2011-06-14 哥们儿,你看这样行不行,使用Hudson进行持续集成,你在Hudson配置你的web应用,让Huson定时去SVN库check代码,若发现SVN库源代码source code有变更,会自动下载,编译的。让你的web项目依赖于其他的Maven的jar项目,它会先编译依赖项目,依赖构建完成后再chack主web项目
http://www.docin.com/p-219804521.html
是关于hudson的介绍,持续集成。