I have servlet-api 2.5 provided, but want to use it during integration tests. Is this possible?
I am using the Jersey Test Framework, that includes servlet-api 2.5 in the test s开发者_开发百科cope. Unfortunately, I have also written my own custom filter that requires me to have access to servlet-api at compile time. I don't want to elevate the scope to "compile" though, because I still don't want it in the war file. Is there any hope?
It is supposed to just work. To quote the reference:
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
Maven downloads the thing, adds it to test and compile classpaths, but does not include it in packaging.
精彩评论