How to start and stop an Tomcat container with Java?

后端 未结 4 622
野的像风
野的像风 2020-12-16 01:13

I have a Maven project that starts a tomcat container for pre-integration-tests (jUnit Tests). Most of my tests require that the web-application under tests is restarted. So

4条回答
  •  误落风尘
    2020-12-16 01:44

    bootstrap.jar and commons-logging-api-1.1.1 from tomcat\bin to your classpath and the following snippet may help,

    Bootstrap bootstrap=new Bootstrap();
    bootstrap.setCatalinaHome("D:/apache-tomcat-5.5.28");
    
    bootstrap.start();
    
    Thread.sleep(60000);
    
    bootstrap.stop();
    

提交回复
热议问题