Turn http://www.cnblogs.com/nightswatch/p/4639687.html
I. Eclipse Jetty plug-in installation:
Open Eclipse, click menu Help->eclipse Marketplace, enter jetty in the box after find, select the first item to install.
Two. Use of the jetty plugin:
The configuration of the Pom file:
<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/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <groupId>com.jetty.TestNG</groupId> <artifactId> Jetty-testng</artifactid> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging > <name>jetty-TestNG</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependenc ies> <dependency> <groupId>junit</groupId> <artifactid>junit</a rtifactid> <version>3.8.1</version> <scope>test</scope> </depen Dency> </dependencies> <build><plugins> <!--jetty Plug-in <plugin> <groupid>org.mortbay.jett Y</groupid> <artifactId>maven-jetty-plugin</artifactId> <version>6.1 .5</version> <configuration> <webappsourcedirectory>src/main/webapp< ;/webappsourcedirectory> <scanIntervalSeconds>3</scanIntervalSeconds> <contextPath>/jetty</contextPath> <connectors> <connector implementation= "Org.mortbay.jetty.nio.SelectChannelConnector" > <port>4000</port> </connector> </connectors> </configuration> </plugin> </plugins> </build></project>
Note that the above webappsourcedirectory is your own WebApp folder or Wencontent folder, ContextPath: For the first address after the port number, you can take it, port is the port number.
After the code is put into/main/java, it can be executed under the project directory:
MVN compile to do the compilation attempt,
You can also generate a packaged file directly with the MVN war.
Of course, you can finally run your webapp! with MVN jetty:run.
(3) Configure jetty for debugging in Eclipse:
First, configure an external tool to run Jetty:
Select Menu Run->external tools->external Tools ... Select Program on the left, then click New:
Configure location as MVN full command line.
Select working directory for this project.
Arguments fill in: Jetty:run
Then click on the enviroment page: Add the maven_opts variable with the value:
-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y
Where, if suspend=n means not to debug, run directly.
Then, click Apply, and then close the dialog box.
Also note that it seems that the external Tool menu item appears in the Java browering perspective. If you can't see it under Java, you can switch to try it.
Create a new run configuration below:
Click to select Run->debug ...
Select the remote Java application in the left tree and click New.
The key to selecting your project is to fill in the same port number as before when you set up the external tool. (In fact, the most terminal number is determined by the port in Pom.xml, such as the above 4000, here can be different)
The configuration is complete, and the front start debugging runs:
The first thing to do is to run the jetty (a bit like the running AppServer in Tomcat), select the previously configured external tool from Run->external tools to run, and the log will show:
Listening at Port 4000,
Then choose Run->debug Select our newly built run configuration, then the program run up, you can access through the Web, set breakpoints debugging.
Use jetty with Maven in 2.idea:
method, like Eclipse, also builds a MAVEN project, Using the same Pom.xml file, you can directly click on the Maven tab on the right side of idea, and under plugins there is a jetty option, expand any point that can start jetty, and then enter the address in the browser to access the Web App.
Install under the MAVEN environment under Eclipse Run jetty