如何使用jetty自動熱部署修改後的全部文件,好比js,jpg,class等,哇咔咔 太爽啦比tomcat舒服多了。css
jetty模式是不能修改js文件的,好比你如今調試前端js,發如今myeclipse/eclipse的源碼裏面沒法修改文件,點都不讓你點,因此,你只能採用一些辦法,更改jetty的模式配置。html
Look:前端
1.從jetty.jar中解出webdefault.xml(位於org.mortbay.jetty.webapp包下)這個文件,在<servlet>節點下把這個useFileMappedBuffer參數設爲false,大概就在153行左右,外國人寫的N多註釋結束的20行以後。java
<init-param> <param-name>useFileMappedBuffer</param-name> <!-- change to false --> <param-value>true</param-value> </init-param>
2.把修改後的webdefault.xml文件放到一個地方,隨便放,我放在了src/main/resources下了web
3.修改你的maven核心pom.xml文件apache
<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你的靜態文件。tomcat
webAppConfig : 工程根目錄,目的是爲了編譯java源碼後自動部署到jetty,爽吧,不用部署了,自動熱部署哦~~ ctrl + s 以後你就能夠在瀏覽器觀看效果咯~~oracle
4.直接項目右鍵 運行maven的命令 jetty:runapp
控制檯 :
[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