Tomcat - starting webapps in a specific order

前端 未结 9 631
既然无缘
既然无缘 2020-12-05 07:51

I know that Tomcat and the Servlet spec do not support starting webapps in a particular order.

However, this seems to me like a common use case, and I\'m wondering i

9条回答
  •  抹茶落季
    2020-12-05 08:53

    That's quite easy to achieve if you don't care hacking a bit of tomcat code and creating your own Host instance

    1) Create a subClass of org.apache.catalina.core.StandardHost, say MyHost:

        class MyHost extends org.apache.catalina.core.StandardHost{
            public MyHost (){
            super();
            //changing HashMap for a predictable ordered Map :)
            this.children = new LinkedHashMap();
            }
        } 
    

    2) register your class on your server's xml Host tag ()

    Incredible as it may seem, it solves the problem as long as you have all your web app declared in the correct order inside of Host tag:

        
         
         
       
    

    Thaen app1 will start before app2, no matter which SO you used.

提交回复
热议问题