2016-09-16 125 views
-1

Project Structure未能執行目標org.apache.maven.plugins

我想用CMD運行pom.xml的,但是當我使用的命令MVN安裝我收到以下錯誤,第一個是pom.xml中而第二個是附加的CMD導致窗口,請

的pom.xml:

<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.48.2</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.10</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> 
    <!--  
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>6.0.2</version> 
     </dependency> --> 

    </dependencies> 

    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>2.19.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> 

CMD:

<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.48.2</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.10</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> 
    <!--  
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>6.0.2</version> 
     </dependency> --> 

    </dependencies> 

    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>2.19.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> 
CMD RESULT: 


C:\Users\Shashank_bisht\workspace\SampleProject>mvn clean install 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building SampleProject 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[WARNING] The POM for org.testng:testng:jar:5.14.3 is invalid, transitive dependencies (if any) will not be ava 
ilable, enable debug logging for more details 
[WARNING] The POM for org.testng:testng:jar:5.14.4 is invalid, transitive dependencies (if any) will not be ava 
ilable, enable debug logging for more details 
[WARNING] The POM for org.testng:testng:jar:5.14.5 is invalid, transitive dependencies (if any) will not be ava 
ilable, enable debug logging for more details 
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ SampleProject --- 
[INFO] Deleting C:\Users\Shashank_bisht\workspace\SampleProject\target 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SampleProject --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory C:\Users\Shashank_bisht\workspace\SampleProject\src\main\resources 
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ SampleProject --- 
[INFO] Changes detected - recompiling the module! 
[INFO] Compiling 12 source files to C:\Users\Shashank_bisht\workspace\SampleProject\target\classes 
[INFO] ------------------------------------------------------------- 
[ERROR] COMPILATION ERROR : 
[INFO] ------------------------------------------------------------- 
[ERROR] /C:/Users/Shashank_bisht/workspace/SampleProject/src/main/java/tiger/Marketing/CreateLeadPage.java:[8,4 
7] package tiger.SampleProject.MyHomepageTestCases does not exist 
[INFO] 1 error 
[INFO] ------------------------------------------------------------- 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 6.252 s 
[INFO] Finished at: 2016-09-16T16:01:57+05:30 
[INFO] Final Memory: 18M/152M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on 
project SampleProject: Compilation failure 
[ERROR] /C:/Users/Shashank_bisht/workspace/SampleProject/src/main/java/tiger/Marketing/CreateLeadPage.java:[8,4 
7] package tiger.SampleProject.MyHomepageTestCases does not exist 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 

回答

0

基於錯誤日誌,它看起來像CreatingLeadPage.java正在嘗試導入tiger.SampleProject.MyHomepageTestCases類,它無法找到,因爲此類可能不會作爲源代碼的一部分存在。 你應該添加這個類文件來編譯你的代碼。

+0

好的,我有兩個文件夾src/main/java和src/test/java,maven正在做什麼,它是指向src/main/java而不是src/test/java,其中我的測試類是,我怎麼指向的Maven來執行測試類,而不是進入src/main/java?只是提到我已經添加了上面我的文件夾結構的圖片,請參閱上面的圖片。謝謝 –

相關問題