插件
方法一:
eclipse 更新地址:http://run-jetty-run.googlecode.com/svn/trunk/updatesite/。
方法二:
利用SVN 更新地址:http://run-jetty-run.googlecode.com/svn/trunk/updatesite/,然后已link方式到eclipse中
jar包依赖 java程序启动
创建maven项目 mvn archetype:create -DgroupId=cn.everlook.myweb -DartifactId=myweb -DpackageName=cn.everlook.myweb
mvn archetype:create -DgroupId=cn.everlook.myweb -DartifactId=myweb -DarchetypeArtifactId=maven-archetype-webapp
pom.xml配置
1.依赖jar包
<!-- jetty -->
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>${jetty.version}</version>
<scope>compile</scope>
</dependency>
<!-- TEST end -->
2.相关插件
<artifactId>system</artifactId>
<!-- jetty插件, 设定context path与spring profile -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<systemProperties>
<systemProperty>
<name>spring.profiles.active</name>
<value>development</value>
</systemProperty>
</systemProperties>
<useTestClasspath>true</useTestClasspath>
<webAppConfig>
<contextPath>/${project.artifactId}</contextPath>
</webAppConfig>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Xms1024m</argument>
<argument>-XX:PermSize=128m</argument>
<argument>-XX:MaxNewSize=512m</argument>
<argument>-XX:MaxPermSize=256m</argument>
<argument>-classpath</argument>
<classpath />
<argument>com.bamboo.common.jetty.QuickStartServer</argument> <!-- 程序入口,主类名称 -->
</arguments>
</configuration>
</plugin>
package com.bamboo.common.jetty;
import org.eclipse.jetty.server.Server;
/**
* 使用Jetty运行调试Web应用, 在Console输入回车快速重新加载应用.
*
* @author calvin
*/
public class QuickStartServer {
public static final int PORT = 9090;
public static final String CONTEXT = "/alex";
public static final String[] TLD_JAR_NAMES = new String[] { "sitemesh", "spring-webmvc", "shiro-web" };
public static void main(String[] args) throws Exception {
// 设定Spring的profile
System.setProperty("spring.profiles.active", "development");
// 启动Jetty
long startTime = System.currentTimeMillis();
Server server = JettyFactory.createServerInSource(PORT, CONTEXT);
JettyFactory.setTldJarNames(server, TLD_JAR_NAMES);
try {
server.start();
long time = System.currentTimeMillis() - startTime;
System.out.println("Server startup in " + time + " ms, running at http://localhost:" + PORT + CONTEXT);
System.out.println("Hit Enter to reload the application quickly");
// 等待用户输入回车重载应用.
while (true) {
char c = (char) System.in.read();
if (c == '\n') {
JettyFactory.reloadContext(server);
}
}
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
}