I am deploying a web application in a Jetty container and I need to k开发者_运维百科now how to add a classpath for Jetty to be able to load resources from a testing directory.
I think it's best to not modify the Jetty CLASSPATH; use what you know about the defaults for your web app.
All the JARs in WEB-INF/lib are your web app's CLASSPATH; so are all paths relative to WEB-INF/classes. 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.
I find it much easier to keep my test jars in a separate folder where they are built by a different process or 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
精彩评论