maven-jetty插件未使用正确的路径 [英] maven-jetty plugin not using correct paths

查看:348
本文介绍了maven-jetty插件未使用正确的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jetty-maven插件来部署用于集成测试的Web应用程序.我有一个包含两个POM的项目.一个在根目录中,一个在项目根目录中(称为webapp目录).当我从maven(使用jetty-maven插件)运行集成测试时,在webapp目录中,它的运行情况非常好.但是,当我从根目录运行它时,它将进入webapp目录中并运行测试,但是由于某种原因,它将路径弄错了. (因此,找不到所有资源.)

I am using the jetty-maven plugin to deploy a web-app for integration testing. I have a project which consists of a two POMs. One in the root, and one in a directory in the project root (call this the webapp directory). When I run the integration test from maven (which uses the jetty-maven plugin), in the webapp directory, it works perfectly fine. However, when I run it from the root directory, it goes inside the webapp directory and runs the test but for some reason it gets the paths wrong. (As a result, all resources cannot be found).

它将根目录路径连接到webapp资源路径.它还不了解路径中的点运算符.

It concatenates the root directory path to the webapp resources path. It also does not understand the dot operator in a path.

例如:如果要查找"./resources/resource.xml"

For example: if it was to look for "./resources/resource.xml"

如果从webapp目录运行测试会很好,但是,如果从根目录运行,它将生成路径:"c:/project/./resources/resource.xml".是通过jetty-maven插件执行的,但我不确定为什么.

It would work fine if the test was run from the webapp directory, however if run from the root directory it will make the path: "c:/project/./resources/resource.xml". It is the jetty-maven plugin that is doing this but I am not sure why.

有没有办法解决这个问题?

Is there a way to fix this?

这是我的Webapp目录POM的相关部分

Here is relevant part of my webapp directory POM

              <groupId>org.mortbay.jetty</groupId>
              <artifactId>jetty-maven-plugin</artifactId>
              <configuration>
                   <webApp>${basedir}/target/webappSNAPSHOT.war</webApp>
                   <extraClasspath>${project.build.testOutputDirectory}</extraClasspath>
                   <testClassesDirectory>${basedir}/target/test-classes</testClassesDirectory>
                   <useTestClasspath>true</useTestClasspath>
                   <stopPort>9929</stopPort>
                   <stopKey>stopKey</stopKey>

              </configuration>

推荐答案

您很可能只需要在Web应用程序资源路径中指定$ {basedir}.

Most likely you just need to specify ${basedir} in your web app resources path.

这篇关于maven-jetty插件未使用正确的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆