[英]Can't create maven project from console on Windows - error
我試圖在Windows XP中生成maven項目。
我用pom.xml
創建了文件夾:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>selenium.web.driver</groupId>
<artifactId>OMS_selenium_Test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>selenium_tests</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<scope></scope>
</dependency>
</dependencies>
</project>
打開cmd
並進入此文件夾。
運行下一個命令:
C:\Documents and Settings\Admintemp\maven_test>mvn archetype:generate -DgroupId=
selenium.web.driver -DartifactId=OMS_selenium_Test -Dversion=1.0-SNAPSHOT -Dinte
ractiveMode=false
我沒有使用這些數據生成項目,而是抓住了下一個錯誤:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.2:generate (default-cli) on project OMS_selenium_Test: Unable to add module to
the current project as it is not of packaging type 'pom' -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
為什么會這樣呢? 也許我想念smt,但我無法弄明白到底是什么......
你的錯誤是手工創建一個POM文件。 當您運行您嘗試的命令時,Maven將自動執行此操作。 刪除您的POM文件並嘗試再次運行該命令。
Maven假設您想要將子模塊添加到現有的Maven項目中。 這失敗了,因為當你期望一個“pom”項目時,你現有的POM文件是“jar”項目(例如普通的Java代碼)。
當您從運行mvn原型的同一文件夾中運行generate命令時會發生這種情況:create-from-project from(或者在這種情況下,您生成的POM使得maven認為這是一個現有項目)。
Ernestas的回答很有效,因為他們切換到另一個文件夾並運行相同的命令。
好吧,我嘗試了以下命令,它對我有用:
> cd C:\Temp
> mvn archetype:generate -DgroupId=selenium.web.driver -DartifactId=OMS_selenium_Test -Dversion=1.0-SNAPSHOT -DinteractiveMode=false
編輯現在我有我的項目:C:\\ Temp \\ OMS_selenium_Test
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.