Why can't my jar files and my .war file be found within my project build? Maven

懵懂的女人 提交于 2019-12-10 22:06:59

问题


Ok so I'm trying to test my Maven app locally with this command:

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

But I'm getting this error:

"Unable to access jarfile target/dependency/jetty-runner.jar."

It also can't seem to access my .war file. I don't know what's going on. I tried manually downloading the jetty-runner.jar file and exporting my project into a war, and then running the command from my desktop where the two files were located, and that worked. So it's gotta be a problem with finding these files.

I found that code online. What is the target/dependency folder? Why isn't my jetty-runner there? It is also unable to find the .war file in target. I know this cause I used my manually downloaded jetty-runner.jar with target/.war and it still failed with this:

"java.net.MalformedURLException: no protocol: target/*war"

I did include the jetty-runner in my pom.xml:

<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>

So what gives? What is this target folder? and why can't anything be found? Thanks!


回答1:


Solved it, had to run:

mvn package

or in my case, I ran my project as Maven Build... in eclipse and typed "package" into goal. This put the files in the necessary places



来源:https://stackoverflow.com/questions/19260293/why-cant-my-jar-files-and-my-war-file-be-found-within-my-project-build-maven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!