当前位置: 首页>>代码示例>>Java>>正文


Java WebResourceRoot.addPreResources方法代码示例

本文整理汇总了Java中org.apache.catalina.WebResourceRoot.addPreResources方法的典型用法代码示例。如果您正苦于以下问题:Java WebResourceRoot.addPreResources方法的具体用法?Java WebResourceRoot.addPreResources怎么用?Java WebResourceRoot.addPreResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.WebResourceRoot的用法示例。


在下文中一共展示了WebResourceRoot.addPreResources方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.catalina.WebResourceRoot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
    String userDir = System.getProperty("user.dir") + File.separator + "server.tomcat";
    String webappDirLocation = userDir + File.separator +"src/main/webapp/";
    Tomcat tomcat = new Tomcat();

    String webPort = System.getenv("PORT");
    if (webPort == null || webPort.isEmpty())
    {
        webPort = "8080";
    }

    tomcat.setPort(Integer.valueOf(webPort));

    System.out.println("configuring app with basedir: " + new File(webappDirLocation).getAbsolutePath());

    StandardContext standardContext = (StandardContext) tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
    File additionWebInfClasses = new File(userDir + File.separator + "build/classes");
    WebResourceRoot resourceRoot = new StandardRoot(standardContext);
    resourceRoot.addPreResources(new DirResourceSet(resourceRoot, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
    standardContext.setResources(resourceRoot);

    tomcat.start();
    tomcat.getServer().await();
}
 
开发者ID:geekflow,项目名称:light,代码行数:26,代码来源:TomcatMain.java

示例2: setUpClass

import org.apache.catalina.WebResourceRoot; //导入方法依赖的package包/类
/**
 * Sets up the test environment, generates data to upload, starts a
 * Tomcat instance which will receive the client requests.
 * @throws Exception If an error occurred with the servlets
 */
@BeforeClass
public static void setUpClass() throws Exception {
    server = new Tomcat();

    Path base = Paths.get("build/tomcat");
    Files.createDirectories(base);

    server.setPort(8100);
    server.setBaseDir("build/tomcat");
    server.getHost().setAppBase("build/tomcat");
    server.getHost().setAutoDeploy(true);
    server.getHost().setDeployOnStartup(true);

    StandardContext context = (StandardContext) server.addWebapp("/", base.toAbsolutePath().toString());

    Path additionWebInfClasses = Paths.get("build/classes");
    WebResourceRoot resources = new StandardRoot(context);
    resources.addPreResources(new DirResourceSet(resources, "/WEB-INF/classes",
            additionWebInfClasses.toAbsolutePath().toString(), "/"));
    context.setResources(resources);
    context.getJarScanner().setJarScanFilter((jarScanType, jarName) -> false);

    server.start();
}
 
开发者ID:Elopteryx,项目名称:upload-parser,代码行数:30,代码来源:TomcatIntegrationTest.java

示例3: main

import org.apache.catalina.WebResourceRoot; //导入方法依赖的package包/类
public static void main(String[] args) {
	Connector connector = new Connector();
	connector.setPort(80);
	Tomcat tomcat = new Tomcat();
	tomcat.setPort(80);
	tomcat.getService().addConnector(connector);
	tomcat.setConnector(connector);
	try {
		Context ctx = tomcat.addWebapp("", Conf.getAbsolutePath("../src/main/webapp"));
		WebResourceRoot resources = new StandardRoot(ctx);
		resources.addPreResources(new DirResourceSet(resources,
				"/WEB-INF/classes", Conf.getAbsolutePath("classes"), "/"));
		ctx.setResources(resources);

		Server server = tomcat.getServer();
		server.start();
		server.setPort(8005);
		server.await();
		server.stop();
	} catch (ServletException | LifecycleException e) {
		Log.e(e);
	}
}
 
开发者ID:xqbase,项目名称:metric,代码行数:24,代码来源:Startup.java

示例4: main

import org.apache.catalina.WebResourceRoot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        String webappDirLocation = "src/main/webapp/";
        Tomcat tomcat = new Tomcat();

        //The port that we should run on can be set into an environment variable
        //Look for that variable and default to 8080 if it isn't there.
        String webPort = System.getenv("PORT");
        if(webPort == null || webPort.isEmpty()) {
            webPort = "8080";
        }

        tomcat.setPort(Integer.valueOf(webPort));

        StandardContext ctx = (StandardContext) tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
        System.out.println("configuring app with basedir: " + new File("./" + webappDirLocation).getAbsolutePath());

        // Declare an alternative location for your "WEB-INF/classes" dir
        // Servlet 3.0 annotation will work
        File additionWebInfClasses = new File("target/classes");
        WebResourceRoot resources = new StandardRoot(ctx);
        resources.addPreResources(new DirResourceSet(resources, "/WEB-INF/classes",
                additionWebInfClasses.getAbsolutePath(), "/"));
        ctx.setResources(resources);

        tomcat.start();
        tomcat.getServer().await();
    }
 
开发者ID:salesforceidentity,项目名称:heroku-identity-java,代码行数:29,代码来源:Main.java

示例5: main

import org.apache.catalina.WebResourceRoot; //导入方法依赖的package包/类
public static void main(String[] args) {
	Connector connector = new Connector();
	connector.setPort(80);
	Tomcat tomcat = new Tomcat();
	tomcat.setPort(80);
	tomcat.getService().addConnector(connector);
	tomcat.setConnector(connector);
	try {
		Context ctx = tomcat.addWebapp("", Conf.getAbsolutePath("../src/main/webapp"));
		// Ensure to Load All Classes in the Same Class Loader
		ctx.setLoader(new WebappLoader(Startup.class.getClassLoader()) {
			@Override
			public ClassLoader getClassLoader() {
				return Startup.class.getClassLoader();
			}
		});
		WebResourceRoot resources = new StandardRoot(ctx);
		resources.addPreResources(new DirResourceSet(resources,
				"/WEB-INF/classes", Conf.getAbsolutePath("classes"), "/"));
		ctx.setResources(resources);

		Server server = tomcat.getServer();
		server.start();
		server.setPort(8005);
		server.await();
		server.stop();
	} catch (ServletException | LifecycleException e) {
		Log.e(e);
	}
}
 
开发者ID:xqbase,项目名称:metric,代码行数:31,代码来源:Startup.java


注:本文中的org.apache.catalina.WebResourceRoot.addPreResources方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。