Maven Jetty Plugin

Source: Internet
Author: User

Reprint: Http://blog.163.com/[email protected]/blog/static/1026408072013101311395492/

Foreword: When testing and debugging under MAVEN, compared to Tomcat, Jboss, Jetty, individuals are more inclined to use Jetty Plugin.
What do you say? The best thing about using Jetty Plugin is that you don't have to knock the package, deploy, and then start the server's instructions, just tap one sentence: mvn jetty:run
Or just point to the Run button on Eclipse and it's done. And even better, you modify the resource file, Jetty can automatically scan to and give feedback in time to reload,
This is useful for modifying Java files, without having to restart the server every time the Java files are modified, eliminating the need to waste a lot of time.
Of course, if you want Jetty to run better, you also need to prohibit Jetty from using the mapped cache.

Environment: Maven 3.0.4
Eclipse 3.6
Maven-jetty-plugin 6.1.10
Project structure:


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/maven-v4_0_0.xsd" >

<modelVersion>4.0.0</modelVersion>
<groupId>com.fancy</groupId>
<artifactId>jetty-plugin-demo</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>jetty-plugin-demo Maven webapp</name>
<url>http://maven.apache.org</url>

<build>
<finalName>jetty-plugin-demo</finalName>
<plugins>
<!--Maven Jetty Plugin--
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<!--scan every 2 seconds for hot deployment--
<scanIntervalSeconds>2</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>

</project>
index.jsp
<body>
</body>
Select the item, right-click Run as---Maven build
Name: Take a name on your own
Goals: Enter the MAVEN command to execute
The rest of the tube, click Run directly



After the Jetty run is complete, visit: http://localhost:8080/jetty-plugin-demo/


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Prohibit Jetty from using mapped caches:

When you want to try to modify the resource files that are being accessed, such as CSS, JS, FTL, and so on, when you modify the complete want to save, is not saved.
You must stop the Jetty container (if it is a Jetty container running under cmd, press Ctrl + C to stop Jetty) before saving. After saving is complete, you must
Restart the Jetty container to see the effect. Doing so is both cumbersome and unpleasant for modifying. css,. js,. FTL, and so on.

The reason for this is that Jetty uses a memory-mapped file to cache static files. Under Windows, using a memory-mapped file causes the file to be locked.
The solution is not to use a memory-mapped file for caching. The steps are as follows:

The jar package corresponding to the Jetty version is found in the local Maven repository based on the version of Jetty used.

Such as:
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
</plugin>
</plugins>

You need to find (my local maven repository is in D:\Repositories\Maven):
D:\Repositories\Maven\org\mortbay\jetty\jetty\6.1.10\jetty-6.1.10.jar

Open the jar package with the Unzip tool and go to:
Jetty-6.1.10.jar\org\mortbay\jetty\webapp
Locate the Webdefault.xml file, which is: Jetty-6.1.10.jar\org\mortbay\jetty\webapp\webdefault.xml
Extract this file Webdefault.xml to find:
<param-name>useFileMappedBuffer</param-name>
<param-value>true</param-value>

Change true to False to prohibit the use of the mapped cache.

Delete the Webdefault.xml file from the original jar package, compress the modified Webdefault.xml file, OK. Get.

This allows you to modify and save the resource file when the Jetty is running.




Http://www.blogjava.net/fancydeepin/archive/2012/06/23/maven-jetty-plugin.html

Maven Jetty Plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.