jeecg3.5使用内嵌的jetty进行调试开发

在pom.xml中增加以下配置,引入jetty相关jar包,其中${jetty.version}是具体的jetty的版本,我用的是6.1.25,用其它版本应该也是可以的:

<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty</artifactId>
			<version>${jetty.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jsp-2.1-jetty</artifactId>
			<version>${jetty.version}</version>
			<scope>test</scope>
		</dependency>

注释掉以下配置,因为会和引入的jetty冲突:

<!-- 
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jsp-api</artifactId>
			<version>2.0</version>
			<scope>provided</scope>
		</dependency>
		
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>
		 -->

然后重新运行:mvn eclipse:eclipse

在eclipse中右键刷新工程,在src\main\java\test下增加下面这个类

package test;

import org.mortbay.jetty.Server;
import org.mortbay.jetty.webapp.WebAppContext;


public class StartJetty {

	public static final int PORT = 8080;
	public static final String CONTEXT = "/jeecg";
	public static final String BASE_URL = "http://localhost:8080/jeecg";

	public static void main(String[] args) throws Exception {
		Server server = buildNormalServer(PORT, CONTEXT);
		server.start(); 
		
		

		System.out.println("Hit Enter in console to stop server");
		if (System.in.read() != 0) {
			server.stop();
			System.out.println("Server stopped");
			System.exit(0);
		}
	}
	
	public static Server buildNormalServer(int port, String contextPath) {
		Server server = new Server(port);
		WebAppContext webContext = new WebAppContext("src/main/webapp", contextPath);
		webContext.setClassLoader(Thread.currentThread().getContextClassLoader());
		server.setHandler(webContext);
		server.setStopAtShutdown(true);
		return server;
	}
}

然后每次只要运行这个类就可以愉快的进行调试运行啦!

这个类是参考spring-side工程的,谢谢江南白衣!

转载于:https://my.oschina.net/u/914897/blog/392900

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值