沉睡森林@漂在北京

本处文章除注明“转载”外均为原创,转载请注明出处。

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  152 随笔 :: 4 文章 :: 114 评论 :: 0 Trackbacks
  最近准备离职了,等着到20号离开。所以在公司里面没有什么事情,自己研究了一下maven。以前对他的认识主要是依赖管理,而这几天的学习,对他的plugin机制影响特别深刻。特别的是jetty插件的使用,十分方便。
  
  首先需要下载eclipse,推荐最新的Helios版本,安装m2eclipse插件,更新地址为:http://m2eclipse.sonatype.org/sites/m2e/0.10.2.20100623-1649/。新建一个maven项目,并且使用下面的pom文件。具体代码如下:

<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>cn.gwssi</groupId>
    
<artifactId>gwssi-extjsptags-demo</artifactId>
    
<packaging>war</packaging>
    
<version>1.0.1-SNAPSHOT</version>
    
<name>gwssi-extjsptags-demo Maven Webapp</name>
    
<url>http://maven.apache.org</url>
    
<dependencies>

        
<!-- J2EE相关依赖jar包 -->
        
<dependency>
            
<groupId>org.apache.openejb</groupId>
            
<artifactId>javaee-api</artifactId>
            
<version>5.0-1</version>
            
<scope>provided</scope>
        
</dependency>
        
<dependency>
            
<groupId>javax.faces</groupId>
            
<artifactId>jsf-api</artifactId>
            
<version>1.2_04</version>
            
<scope>provided</scope>
        
</dependency>
        
<dependency>
            
<groupId>javax.servlet</groupId>
            
<artifactId>jstl</artifactId>
            
<version>1.2</version>
            
<scope>provided</scope>
        
</dependency>
        
<dependency>
            
<groupId>javax.servlet.jsp</groupId>
            
<artifactId>jsp-api</artifactId>
            
<version>2.1</version>
            
<scope>provided</scope>
        
</dependency>
        
<dependency>
            
<groupId>javax.faces</groupId>
            
<artifactId>jsf-impl</artifactId>
            
<version>1.2_04</version>
            
<scope>provided</scope>
        
</dependency>
        
<!-- J2EE相关依赖jar包~~~~~~~~~~~~结束 -->

        
<!-- pojo copy (usually for webservice) -->
        
<dependency>
            
<groupId>net.sf.dozer</groupId>
            
<artifactId>dozer</artifactId>
            
<version>5.2.0</version>
        
</dependency>

        
<dependency>
            
<groupId>junit</groupId>
            
<artifactId>junit</artifactId>
            
<version>4.8.1</version>
            
<type>jar</type>
            
<scope>test</scope>
        
</dependency>

        
<dependency>
            
<groupId>taglibs</groupId>
            
<artifactId>standard</artifactId>
            
<version>1.1.2</version>
        
</dependency>
    
</dependencies>
    
<build>
        
<finalName>gwssi-extjsptags-demo</finalName>
        
<plugins>
            
<plugin>
                
<groupId>org.apache.maven.plugins</groupId>
                
<artifactId>maven-compiler-plugin</artifactId>
                
<configuration>
                    
<source>1.5</source>
                    
<target>1.5</target>
                    
<encoding>UTF-8</encoding>
                
</configuration>
            
</plugin>
            
<plugin>
                
<groupId>org.apache.maven.plugins</groupId>
                
<artifactId>maven-javadoc-plugin</artifactId>
                
<configuration>
                    
<charset>UTF-8</charset>
                
</configuration>
            
</plugin>
            
<plugin>
                
<groupId>org.mortbay.jetty</groupId>
                
<artifactId>jetty-maven-plugin</artifactId>
                
<version>7.1.0.RC1</version>
                
<configuration>
                    
<scanIntervalSeconds>10</scanIntervalSeconds>
                    
<stopKey>foo</stopKey>
                    
<stopPort>9999</stopPort>
                
</configuration>
                
<dependencies>
                    
<dependency>
                        
<groupId>commons-logging</groupId>
                        
<artifactId>commons-logging</artifactId>
                        
<version>1.1</version>
                        
<type>jar</type>
                    
</dependency>
                    
<dependency>
                        
<groupId>org.slf4j</groupId>
                        
<artifactId>slf4j-jcl</artifactId>
                        
<version>1.0.1</version>
                        
<type>jar</type>
                    
</dependency>
                    
<dependency>
                        
<groupId>log4j</groupId>
                        
<artifactId>log4j</artifactId>
                        
<version>1.2.13</version>
                        
<type>jar</type>
                    
</dependency>
                
</dependencies>
            
</plugin>
        
</plugins>
    
</build>
</project>

  在eclipse中选择菜单run-》external tools进入,配置2个命令:jetty_run和jetty_stop。其中run命令location为$MAVEN_HOME/bin/mvn.bat,working directory选择当前项目即可,参数输入:-Dslf4j=false -Dlog4j.configuration=file:./target/classes/log4j.properties   jetty:run。
  stop命令和run命令前面2项相同,参数输入:jetty:stop。

  配置完上面的东西,你马上可以开始一个maven+jetty项目,运行run即可访问http://localhost:8080访问web页面,运行stop关闭服务器。


posted on 2010-07-08 20:27 王总兵 阅读(1547) 评论(2)  编辑  收藏 所属分类: Other

评论

# re: maven+jetty开发实例 2010-07-13 17:44 向前走的螃蟹
哥们你咋装上的m2eclipse的?能告诉告诉我吗?如具体的eclipse版本,还有装之前还要装些什么啊。详细点啊。我公司要用这东西,死活装不上。帮个忙  回复  更多评论
  

# re: maven+jetty开发实例 2010-07-13 19:03 wangchangbing
@向前走的螃蟹
我使用的是最新的eclipse-jee-helios-win32版本
另外,m2eclipse直接使用更新地址进行更新

如果还不够详细,你可以发邮件给我
wangchangbing@gmail.com  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: