简体   繁体   English

如何更改类路径或为 Jetty 添加类路径

[英]How to change the classpath or add classpath for Jetty

I am deploying a web application in a Jetty container and I need to know how to add a classpath for Jetty to be able to load resources from a testing directory.我正在 Jetty 容器中部署 web 应用程序,我需要知道如何为 Jetty 添加类路径以便能够从测试目录加载资源。

I think it's best to not modify the Jetty CLASSPATH;我认为最好不要修改Jetty CLASSPATH; use what you know about the defaults for your web app.使用您对 web 应用程序默认值的了解。

All the JARs in WEB-INF/lib are your web app's CLASSPATH; WEB-INF/lib 中的所有 JARs 都是您的 web 应用程序的 CLASSPATH; so are all paths relative to WEB-INF/classes.所有相对于 WEB-INF/类的路径也是如此。 If you put a directory /test-resources under WEB-INF/classes and load it as a resource stream from the context you'll be able to access those test files without having to alter the Jetty startup scripts.如果您将目录 /test-resources 放在 WEB-INF/classes 下并将其作为资源 stream 从上下文加载,您将能够访问这些测试文件而无需更改 Jetty 启动脚本。

I find it much easier to keep my test jars in a separate folder where they are built by a different process or IDE.我发现将我的测试 jars 保存在一个单独的文件夹中要容易得多,它们由不同的进程或 IDE 构建。

I extracted start.config from the Jetty jar and added my classpath to it as documented at http://docs.codehaus.org/display/JETTY/A+look+at+the+start.jar+mechanism我从 Jetty jar 中提取 start.config 并将我的类路径添加到它,如http://docs.codehaus.org/display/JETTY/A+look+at+the+start.jar+mechanism中所述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM