【问题标题】:Why can't my jar files and my .war file be found within my project build? Maven为什么在我的项目构建中找不到我的 jar 文件和我的 .war 文件?马文
【发布时间】:2023-03-08 12:33:01
【问题描述】:

好的,我正在尝试使用以下命令在本地测试我的 Maven 应用:

java -jar target/dependency/jetty-runner.jar target/*.war

但是我收到了这个错误:

“无法访问jarfile target/dependency/jetty-runner.jar。”

它似乎也无法访问我的 .war 文件。我不知道发生了什么事。我尝试手动下载 jetty-runner.jar 文件并将我的项目导出到战争中,然后从这两个文件所在的桌面运行命令,并且工作正常。所以找到这些文件肯定是个问题。

我在网上找到了该代码。什么是目标/依赖文件夹?为什么我的码头跑者不在那里?它也无法在目标中找到 .war 文件。我知道这是因为我将手动下载的 jetty-runner.jar 与 target/.war 一起使用,但它仍然失败:

“java.net.MalformedURLException:无协议:target/*war”

我确实在我的 pom.xml 中包含了 jetty-runner:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
    <execution>
        <phase>package</phase>
        <goals><goal>copy</goal></goals>
        <configuration>
            <artifactItems>
                <artifactItem>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>jetty-runner</artifactId>
                    <version>7.4.5.v20110725</version>
                    <destFileName>jetty-runner.jar</destFileName>
                </artifactItem>
            </artifactItems>
        </configuration>
    </execution>
</executions>

那是什么?这个目标文件夹是什么?为什么什么都找不到?谢谢!

【问题讨论】:

    标签: java eclipse maven jar jetty


    【解决方案1】:

    解决了,必须运行:

    mvn 包

    或者在我的情况下,我在 Eclipse 中将我的项目作为 Maven Build... 运行并在目标中键入“包”。这会将文件放在必要的地方

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-10
      • 1970-01-01
      • 1970-01-01
      • 2011-07-29
      • 1970-01-01
      • 2020-03-05
      相关资源
      最近更新 更多