美文网首页
嵌入jetty启动web服务

嵌入jetty启动web服务

作者: donglq | 来源:发表于2017-10-12 21:35 被阅读0次
jar包
org.eclipse.jetty:jetty-webapp:9.4.7.RC0
代码
/**
 * 
 */
package com.dlq.blog.start;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

/**
 * @author Donglq
 * @date 2017年9月18日 上午12:10:52
 */
public class StartBlog {

    /**
     * @param args
     */
    public static void main(String[] args) {
        
        Server server = new Server(8080);
        WebAppContext context = new WebAppContext();
        context.setContextPath("/");
        try {
            context.setResourceBase("src/main/webapp");
            server.setHandler(context);
            server.start();
            server.join();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

相关文章

网友评论

      本文标题:嵌入jetty启动web服务

      本文链接:https://www.haomeiwen.com/subject/jitayxtx.html