将类路径添加到在maven集成测试中运行的jetty

发布于 2024-08-20 04:39:04 字数 477 浏览 2 评论 0原文

我正在尝试为生成 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

椵侞 2024-08-27 04:39:04

这应该可以使用 webAppConfig 配置元素(下面的示例取自此线程 ):

<webAppConfig>
  <contextPath>/nportal</contextPath>
  <!-- All I want to do here is add in the /etc/jetty/classes for runtime files. For some reason I have to also add back in the /target/classes directory -->
  <extraClasspath>${basedir}/target/classes/;${basedir}/etc/jetty/classes/</extraClasspath>
</webAppConfig> 

This should be possible using the webAppConfig configuration element (sample below taken from this thread):

<webAppConfig>
  <contextPath>/nportal</contextPath>
  <!-- All I want to do here is add in the /etc/jetty/classes for runtime files. For some reason I have to also add back in the /target/classes directory -->
  <extraClasspath>${basedir}/target/classes/;${basedir}/etc/jetty/classes/</extraClasspath>
</webAppConfig> 
十六岁半 2024-08-27 04:39:04

如果您发现上述解决方案不适合您,请考虑将测试类路径包含到您的 Jetty 配置中。

<configuration>
   <useTestClasspath>true</useTestClasspath>
   ...
</configuration>

然后,这将允许您将各种类型的资源/类放置在测试类路径上,并使它们对 Jetty 服务器可见,而不会渗透到生产代码中。

If you find that the above solution doesn't work for you, consider including the test classpath into your Jetty configuration.

<configuration>
   <useTestClasspath>true</useTestClasspath>
   ...
</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.

梦屿孤独相伴 2024-08-27 04:39:04

您可以将其他配置文件放置在 /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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文