将类路径添加到在maven集成测试中运行的jetty
我正在尝试为生成 war 文件的 Maven 项目设置集成测试。 (如此处所示 http://docs.codehaus.org/display/JETTY/ Maven+Jetty+Plugin/。)但是,我的 war 文件需要类路径上的一堆 .properties 文件,我不想将其捆绑在 war 中。
有没有办法(最好通过插件配置)将文件夹添加到jetty使用的类路径中?
我用谷歌搜索了这个并发现 http://markmail.org/message/awtqrgxxttra3uxx 但这,据我所知可以说,实际上根本不起作用。找不到 .properties 文件。
I'm trying to set up integration tests for a Maven project that produces a war file. (As seen here http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin/.) However I the war file requires a bunch of .properties files on the classpath, that I don't want to bundle in the war.
Is there a way (preferably through plugin configuration) to add a folder to the classpath used by jetty?
I Googled this and found http://markmail.org/message/awtqrgxxttra3uxx but this, as far as I can tell, does not actually work at all. The .properties files are not found.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这应该可以使用
webAppConfig
配置元素(下面的示例取自此线程 ):This should be possible using the
webAppConfig
configuration element (sample below taken from this thread):如果您发现上述解决方案不适合您,请考虑将测试类路径包含到您的 Jetty 配置中。
然后,这将允许您将各种类型的资源/类放置在测试类路径上,并使它们对 Jetty 服务器可见,而不会渗透到生产代码中。
If you find that the above solution doesn't work for you, consider including the test classpath into your Jetty configuration.
This will then allow you to place all manner of resources/classes on the test classpath and have them visible to the Jetty server without them creeping into the production code.
您可以将其他配置文件放置在
/src/test/resources
下,并按照指定的在插件配置中设置属性true
="http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#jetty-run-goal" rel="noreferrer">此处:useTestScope
testClassesDirectory 中的类和范围“test”的依赖项将首先放置在类路径上。默认情况下这是错误的。
You can place your additional configuration files under
/src/test/resources
and set a property<useTestScope>true</useTestScope>
in the plugin configuration as specified here:useTestScope
If true, the classes from testClassesDirectory and dependencies of scope "test" are placed first on the classpath. By default this is false.