zoukankan      html  css  js  c++  java
  • Eclipse + Maven + Jetty 开发WebApp

    作为一句java开发人员,

    (以配置一个Spring+Hibernate+Struts2的WebApp为例)

    你是否为到处网站找jar包以及相关依赖而烦闷不已,

    你是否为它们之间jar包版本不兼容或冲突而怒发冲冠,

    你是否为你电脑上的jar包存放位置而晕头转向,

    你是否为你多个项目之间jar包的共享重用而头疼不已,

    你是否为你的项目构建war包写一大串ant脚本而眼球充血,

    还有 回归测试、持续集成、部署 等诸多问题...

    程序员的时间应该用在写好程序上面,而不应该花太多在这些环节上。

    maven是这些问题的终结者,而且它能做得更多。

    maven会让你更喜欢java.

    “自从搞上maven,眼不酸了,手不疼了,腰脚有力了...”

    ###################################################################

    http://maven.apache.org/

    http://www.eclipse.org/jetty/

    http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin

    http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin

    工具:Eclipse + Maven + Jetty

    插件:m2eclipse, maven-jetty-plugin

    mvn jetty:run -Djetty.port=2222

    pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <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.cg</groupId>
    	<artifactId>test-maven-jetty</artifactId>
    	<packaging>war</packaging>
    	<version>0.0.1-SNAPSHOT</version>
    
    	<name>test-maven-jetty Maven Webapp</name>
    	<url>http://maven.apache.org</url>
    
    	<properties>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    		<!-- Optional: TODO 1 Pick the version of jetty you want. -->
    		<jetty.version>8.1.8.v20121106</jetty.version>
    	</properties>
    
    	<!-- TODO 2 Configure repo2.maven.org as a repository. -->
    	<!-- Optional <repositories> <repository> <id>repo2_maven_org</id> <url>http://repo2.maven.org/maven2</url> 
    		</repository> </repositories> -->
    
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>org.mortbay.jetty</groupId>
    				<artifactId>jetty-maven-plugin</artifactId>
    				<!--old version <artifactId>maven-jetty-plugin</artifactId> -->
    				<!-- Optional -->
    				<version>${jetty.version}</version>
    				<configuration>
    					<!-- 每n秒扫描项目的文件改动,包括java类文件;若为0,一改动保存则重启jetty -->
    					<scanIntervalSeconds>10</scanIntervalSeconds>
    					<stopPort>9999</stopPort>
    					<webApp>
    						<contextPath>/w</contextPath>
    					</webApp>
    				</configuration>
    			</plugin>
    		</plugins>
    	</build>
    
    	<!-- <build> <outputDirectory>${project.basedir}/src/main/webapp/WEB-INF/classes</outputDirectory> 
    		<finalName>test-maven-tomcat</finalName> </build> -->
    
    	<dependencies>
    		<!-- <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> 
    			<version>${jetty.version}</version> </dependency> -->
    		<dependency>
    			<groupId>junit</groupId>
    			<artifactId>junit</artifactId>
    			<version>4.11</version>
    			<scope>test</scope>
    		</dependency>
    	</dependencies>
    
    </project>
    

      

  • 相关阅读:
    POJ 2752 Seek the Name, Seek the Fame
    POJ 2406 Power Strings
    KMP 算法总结
    SGU 275 To xor or not to xor
    hihocoder 1196 高斯消元.二
    hihoCoder 1195 高斯消元.一
    UvaLive 5026 Building Roads
    HDU 2196 computer
    Notions of Flow Networks and Flows
    C/C++代码中的笔误
  • 原文地址:https://www.cnblogs.com/wucg/p/2852661.html
Copyright © 2011-2022 走看看