无法执行maven项目

时间:2015-11-23 08:21:47

标签: java maven selenium-webdriver junit testng

我已将项目从Java更改为Maven。现在尝试执行我的脚本。 没有得到我不正确的地方以及如何使用maven运行我的完整框架。

<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>1MyProjectName</groupId>
  <artifactId>1MyProjectName</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>1MyProjectNameAllDevices</name>
  <description>Testing for multiple devices using remote server access.</description>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
           <mainClass>com.main.DriverScript</mainClass>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

2 个答案:

答案 0 :(得分:0)

只需删除评论......

   <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>1MyProjectName</groupId>
  <artifactId>1MyProjectName</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>1MyProjectNameAllDevices</name>
  <description>Testing for multiple devices using remote server access.</description>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
      </resource>
    </resources>
    <plugins>

    </plugins>
  </build>
</project>

答案 1 :(得分:0)

您可以在pom.xml中定义所有依赖项/ jar文件,如下所示

<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>1MyProjectName</groupId>
 <artifactId>1MyProjectName</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <name>1MyProjectNameAllDevices</name>
 <description>Testing for multiple devices using remote server access.     
 </description>
 <build>
  <sourceDirectory>src</sourceDirectory>
  <resources>
   <resource>
    <directory>src</directory>
    <excludes>
       <exclude>"**/*.java"</exclude> //remove "", comment when you copy this code.
    </excludes>
   </resource>
  </resources>
 </build>
 <dependencies>
 <dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.8.2</version>
  <scope>test</scope>
 </dependency>
 <dependency>
    <artifactId>selenium-java-2.45.0</artifactId>
    <groupId>..</groupId>
    <scope>system</scope>
    <systemPath>${user.home}/softwares/selenium-java-2.45.0.jar</systemPath>
    <version>2.45.0</version>
 </dependency>
 <dependency>
    <artifactId>selenium-server-standalone-2.44.0</artifactId>
    <groupId>..</groupId>
    <scope>system</scope>
    <systemPath>${user.home}/softwares/selenium-server-standalone-2.44.0.jar</systemPath>
    <version>2.44.0</version>
 </dependency>  
 </dependencies>
</project>