| 
 | 
	
 
 
  如何使用jetty自动热部署修改后的所有文件,比如js,jpg,class等,哇咔咔 太爽啦比tomcat舒服多了。 
  jetty模式是不能修改js文件的,比如你现在调试前端js,发现在myeclipse/eclipse的源码里面无法修改文件,点都不让你点,所以,你只能采用一些办法,更改jetty的模式配置。 
  Look: 
  1.从jetty.jar中解出webdefault.xml(位于org.mortbay.jetty.webapp包下)这个文件,在<servlet>节点下把这个useFileMappedBuffer参数设为false,大概就在153行左右,外国人写的N多注释结束的20行之后。 
 
 
 
<init-param> 
<param-name>useFileMappedBuffer</param-name> 
<!-- change to false --> 
<param-value>true</param-value> 
</init-param> 
 
  2.把修改后的webdefault.xml文件放到一个地方,随便放,我放在了src/main/resources下了 
  
 
 
  3.修改你的maven核心pom.xml文件 
 
 
 
<plugin> 
<groupId>org.mortbay.jetty</groupId> 
<artifactId>jetty-maven-plugin</artifactId> 
<version>7.3.0.v20110203</version> 
<configuration> 
<scanIntervalSeconds>10</scanIntervalSeconds> 
<webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml> 
<webAppSourceDirectory>src/main/webapp</webAppSourceDirectory> 
<webAppConfig> 
<contextPath>/report</contextPath> 
</webAppConfig> 
</configuration> 
</plugin> 
  webDefaultXml : 我们在第一步修改好的xml文件 
  webAppSourceDirectory :你的js,css的父级目录,目的是动态部署到jetty你的静态文件。 
  webAppConfig : 工程根目录,目的是为了编译java源码后自动部署到jetty,爽吧,不用部署了,自动热部署哦~~ ctrl + s 之后你就可以在浏览器观看效果咯~~ 
 
  4.直接项目右键 运行maven的命令 jetty:run 
 
  控制台 : 
  [INFO] Started Jetty Server 
  [INFO] Starting scanner at interval of 10 seconds. 
 
  就可以了,随便修改吧,你的项目文件就听你的话了。。太爽了。 
  5.附录我所有的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>com.riambsoft</groupId> 
<artifactId>report</artifactId> 
<packaging>war</packaging> 
<version>0.0.1-SNAPSHOT</version> 
<name>report</name> 
<url>http://www.riambsoft.com</url> 
<dependencies> 
 
<dependency> 
<groupId>org.codehaus.groovy</groupId> 
<artifactId>groovy-all</artifactId> 
<version>1.8.1</version> 
</dependency> 
<!-- jasperreports end --> 
 
<dependency> 
<groupId>com.oracle.driver</groupId> 
<artifactId>jdbc-driver</artifactId> 
<version>10g</version> 
</dependency> 
<dependency> 
<groupId>org.codehaus.plexus</groupId> 
<artifactId>plexus-archiver</artifactId> 
<version>1.0-alpha-7</version> 
</dependency> 
<dependency> 
<groupId>net.sf.opencsv</groupId> 
<artifactId>opencsv</artifactId> 
<version>2.1</version> 
</dependency> 
 
<dependency> 
<groupId>org.codehaus.plexus</groupId> 
<artifactId>plexus-utils</artifactId> 
<version>1.4.7</version> 
</dependency> 
 
<dependency> 
<groupId>com.riambsoft</groupId> 
<artifactId>rsclient.web</artifactId> 
<version>1.0.0_without_RS10</version> 
</dependency> 
</dependencies> 
<build> 
<finalName>report</finalName> 
<plugins> 
 
<plugin> 
<groupId>org.mortbay.jetty</groupId> 
<artifactId>jetty-maven-plugin</artifactId> 
<version>7.3.0.v20110203</version> 
<configuration> 
<scanIntervalSeconds>10</scanIntervalSeconds> 
<webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml> 
<webAppSourceDirectory>src/main/webapp</webAppSourceDirectory> 
<webAppConfig> 
<contextPath>/report</contextPath> 
</webAppConfig> 
</configuration> 
</plugin> 
 
<plugin> 
<groupId>org.mortbay.jetty</groupId> 
<artifactId>maven-jetty-plugin</artifactId> 
<version>6.1.25</version> 
<configuration> 
<scanIntervalSeconds>10</scanIntervalSeconds> 
<webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml> 
<webAppSourceDirectory>src/main/webapp</webAppSourceDirectory> 
</configuration> 
</plugin> 
<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.codehaus.mojo</groupId> 
<artifactId>tomcat-maven-plugin</artifactId> 
<version>1.1</version> 
<configuration> 
<server>tomcat</server> 
<url>http://localhost:8080/manager/html</url> 
<path>/report</path> 
</configuration> 
</plugin> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-javadoc-plugin</artifactId> 
<version>2.9</version> 
<configuration> 
<encoding>UTF-8</encoding> 
</configuration> 
<executions> 
<execution> 
<phase>package</phase> 
<goals> 
<goal>javadoc</goal> 
</goals> 
</execution> 
</executions> 
</plugin> 
 
<!-- 测试覆盖率分析插件 --> 
<plugin> 
<groupId>org.codehaus.mojo</groupId> 
<artifactId>cobertura-maven-plugin</artifactId> 
<version>2.4</version> 
<configuration> 
<encoding>UTF-8</encoding> 
<formats> 
<format>html</format> 
<format>xml</format> 
</formats> 
</configuration> 
<executions> 
<execution> 
<phase>package</phase> 
<goals> 
<goal>cobertura</goal> 
</goals> 
</execution> 
</executions> 
</plugin> 
</plugins> 
</build> 
<description></description> 
</project> 
  2013年7月25日10:15:05 
  落雨 
  qq 394263788 |   
 
 
 
 | 
  
 | 
 | 
 | 
| 
 | 
 |