日期:2014-05-19  浏览次数:20801 次

用Jetty快速开发J2EE应用

对于用Maven管理的项目,可以使用Maven的Jetty插件启动应用进行快速测试。项目的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>com.cdai</groupId>
  <artifactId>struts2-conf</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  
  	<!-- 主要依赖库的版本定义 -->
    <properties>
		<spring.version>3.1.2.RELEASE</spring.version>
		<mybatis.version>3.1.1</mybatis.version>
		<commons-dbcp.version>1.4</commons-dbcp.version>
		<jetty.version>7.6.5.v20120716</jetty.version>
  	</properties>
  
	<dependencies>
	
		<!-- STRUTS2 begin -->
		<dependency>  
            <groupId>org.apache.struts</groupId>  
            <artifactId>struts2-core</artifactId>  
            <version>2.3.1.2</version>  
        </dependency>
        <!-- <dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-spring-plugin</artifactId>
			<version>2.3.1.2</version>
		</dependency> -->
		<!-- STRUTS2 end -->
  	
  		<!-- SPRING begin -->
  	
  		<!-- spring core begin -->
  		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
		<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
			<version>${spring.version}</version>
		</dependency>
  		<!-- spring core end -->
 
  		<!-- spring data access begin -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- spring data access end -->
		
		<!-- SPRING end -->
		
	  	<!-- MYBATIS begin -->
	  	<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>3.1.1</version>
		</dependency>
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>1.1.1</version>
		</dependency>
		<!-- MYBATIS end -->		
		
		<!-- MYSQL begin -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.9</version>
		</dependency>
		<!-- MYSQL end -->

		<!-- COMMON begin -->

		<!-- web begin -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependen