zoukankan      html  css  js  c++  java
  • Atitit 嵌入式tomcat 嵌入式服务器 attilax 你感觉艾提拉 总结 比起嵌入jetty ,文件可以自动刷新貌似还不错。。方便调试debug package com.attilax.

    Atitit 嵌入式tomcat 嵌入式服务器 attilax 你感觉艾提拉 总结

    比起嵌入jetty ,文件可以自动刷新貌似还不错。。方便调试debug

    package com.attilax.web;

    import java.io.File;

    import org.apache.catalina.LifecycleException;

    import org.apache.catalina.core.AprLifecycleListener;

    import org.apache.catalina.core.StandardServer;

    import org.apache.catalina.startup.ClassLoaderFactory;

    import org.apache.catalina.startup.Tomcat;

    import com.attilax.io.pathx;

    import com.attilax.util.Global;

    import javax.servlet.ServletException;

    /**

     * Created by nil on 2014/8/1.

     */

    public class EmbeddedTomcat {

        private Tomcat tomcat;

        private void startTomcat(int port, String contextPath, String baseDir)

                throws ServletException, LifecycleException {

            tomcat = new Tomcat();

            tomcat.setPort(port);

            tomcat.setBaseDir(".");

            StandardServer server = (StandardServer) tomcat.getServer();

            AprLifecycleListener listener = new AprLifecycleListener();

            server.addLifecycleListener(listener);

            tomcat.addWebapp(contextPath, baseDir);

            tomcat.start();

        }

        private void stopTomcat() throws LifecycleException {

            tomcat.stop();

        }

        public static void main(String[] args) {

         System.out.println("");

            try {

                int port = 80;

                String contextPath = "/";

                String baseDir =pathx.webAppPath_jensyegeor();

                 //new File("webroot").getAbsolutePath();  // 项目中web目录名称,以前版本为WebRootwebappwebapps,现在为WebContent

                EmbeddedTomcat tomcat = new EmbeddedTomcat();

                tomcat.startTomcat(port, contextPath, baseDir);

                // 由于Tomcatstart方法为非阻塞方法,加一个线程睡眠模拟线程阻塞.

                

                

                String heartbeat_str = "--tomcat run. heartbeat_str";

               Global.heartbeatRecycle(heartbeat_str);

               

            } catch (Exception e) {

                e.printStackTrace();

            }

        }

    }

    配置简单的嵌入式tomcat - CSDN博客.html

  • 相关阅读:
    第十五节课:习题讲解
    第十四节课:字典
    Python第十三节课-文件的读取和写入
    Python第十二节课--循环语句与注释
    Python第十一节课--字符串的格式化
    Python第十节课==对象的方法
    Python第九节课--初识函数
    初识函数--文件的读取和打开,已一节课一节课分开,可不看
    刷题647. Palindromic Substrings
    刷题617. Merge Two Binary Trees
  • 原文地址:https://www.cnblogs.com/attilax/p/15197674.html
Copyright © 2011-2022 走看看