Maven:找不到jar文件

时间:2016-01-10 14:27:31

标签: maven selenium-webdriver pom.xml

Target Folder之前我使用的是ANT,但是我已经切换到Maven了。我已将包装设置为pom.xml中的JAR。但我的问题是,一旦构建通过,我在哪里可以找到这个jar文件(位置)。我在哪里可以设置pom.xml中的位置,以及它是否必须在pom中添加任何jar插件。 CMD output

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>tiger</groupId>
    <artifactId>SampleProject</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SampleProject</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.45.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.13</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.9.6</version>
        </dependency>

        <!-- //for reportng(guice ,velocity is added) -->
        <dependency>
            <groupId>org.uncommons</groupId>
            <artifactId>reportng</artifactId>
            <version>1.1.4</version>
        </dependency>

        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>3.0</version>
        </dependency>

        <dependency>
            <groupId>velocity</groupId>
            <artifactId>velocity-dep</artifactId>
            <version>1.4</version>
        </dependency>

    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.18.1</version>

                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>testng.xml</suiteXmlFile>
                        </suiteXmlFiles>
                    </configuration>

                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <!-- <reporting> <plugins> TestNG-xslt related configuration. <plugin> <groupId>org.reportyng</groupId> 
        <artifactId>reporty-ng</artifactId> <version>1.2</version> <configuration> 
        Output directory for the testng xslt report <outputDir>/target/testng-xslt-report</outputDir> 
        <sortTestCaseLinks>true</sortTestCaseLinks> <testDetailsFilter>FAIL,SKIP,PASS,CONF,BY_CLASS</testDetailsFilter> 
        <showRuntimeTotals>true</showRuntimeTotals> </configuration> </plugin> </plugins> 
        </reporting> -->


</project>

3 个答案:

答案 0 :(得分:1)

好的家伙我想问题是Chrome浏览器,我尝试用Firefox运行相同的测试它运行正常,得到了BUILD SUCCESS消息和jar也在目标文件夹下。无论如何,谢谢你的帮助。

答案 1 :(得分:0)

这个插件有助于创建我之前使用过的jar。

        <!-- Make this jar executable -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
              <!-- DO NOT include log4j.properties file in your Jar -->
              <excludes>
                <exclude>**/log4j.properties</exclude>
              </excludes>
              <archive>
                <manifest>
                    <!-- Jar file entry point -->
                    <mainClass>com.project.app</mainClass>
                </manifest>
              </archive>
            </configuration>
        </plugin>

进一步请到下面链接进一步了解 https://maven.apache.org/shared/maven-archiver/examples/classpath.html#Make

How can I create an executable JAR with dependencies using Maven?

谢谢

答案 2 :(得分:0)

问题是基于消息this,这意味着您选择了错误的版本(除了给定的版本已经很老)或者您无法访问任何Maven中心进行下载您的依赖项或者您有代理/防火墙...除此之外,您已经开始测试,这些测试正在启动基于selenium的Chrome浏览器,这可能需要一些时间才能启动浏览器或者可能因基于其他问题而卡住...