无法在Windows上从控制台创建maven项目 - 错误

naz*_*art 5 java runtime-error maven

我试图在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>
Run Code Online (Sandbox Code Playgroud)

打开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
Run Code Online (Sandbox Code Playgroud)

我没有使用这些数据生成项目,而是抓住了下一个错误:

[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
Run Code Online (Sandbox Code Playgroud)

为什么会这样呢?也许我想念smt,但我无法弄明白到底是什么......

  • 如何用maven解决这个问题并生成项目?

Dun*_*nes 9

你的错误是手工创建一个POM文件.当您运行您尝试的命令时,Maven将自动执行此操作.删除您的POM文件并尝试再次运行该命令.

Maven假设您想要将子模块添加到现有的Maven项目中.这失败了,因为当你期待一个"pom"项目时,你现有的POM文件是"jar"项目(例如普通的Java代码).