2011-11-17 66 views
0

我正在尝试为Windows 7配置maven 3.0.3。我已经在D盘根目录下了。我喜欢: 环境变量 - >系统变量 - > MAVEN_HOME = D \ apache-maven-3.0.3和系统变量 - > PATH =%JAVA_HOME%\ BIN;%MAVEN_HOME%\ BIN。为Windows 7配置maven

I want to know if it's configured or there is some problem. 

当我输入命令行MVN --3.0.3,它outpts为:

Microsoft Windows [Version 6.1.7601] 
Copyright (c) 2009 Microsoft Corporation. All rights reserved. 

C:\Users\Babar>mvn --3.0.3 
Unable to parse command line options: Unrecognized option: --3.0.3 

usage: mvn [options] [<goal(s)>] [<phase(s)>] 

Options: 
-am,--also-make      If project list is specified, also 
             build projects required by the 
             list 
-amd,--also-make-dependents   If project list is specified, also 
             build projects that depend on 
             projects on the list 
-B,--batch-mode      Run in non-interactive (batch) 
             mode 
-C,--strict-checksums     Fail the build if checksums don't 
             match 
-c,--lax-checksums      Warn if checksums don't match 
-cpu,--check-plugin-updates   Ineffective, only kept for 
             backward compatibility 
-D,--define <arg>      Define a system property 
-e,--errors       Produce execution error messages 
-emp,--encrypt-master-password <arg> Encrypt master security password 
-ep,--encrypt-password <arg>   Encrypt server password 
-f,--file <arg>      Force the use of an alternate POM 
             file. 
-fae,--fail-at-end      Only fail the build afterwards; 
             allow all non-impacted builds to 
             continue 
-ff,--fail-fast      Stop at first failure in 
             reactorized builds 
-fn,--fail-never      NEVER fail the build, regardless 
             of project result 
-gs,--global-settings <arg>   Alternate path for the global 
             settings file 
-h,--help        Display help information 
-l,--log-file <arg>     Log file to where all build output 
             will go. 
-N,--non-recursive      Do not recurse into sub-projects 
-npr,--no-plugin-registry    Ineffective, only kept for 
             backward compatibility 
-npu,--no-plugin-updates    Ineffective, only kept for 
             backward compatibility 
-nsu,--no-snapshot-updates    Suppress SNAPSHOT updates 
-o,--offline       Work offline 
-P,--activate-profiles <arg>   Comma-delimited list of profiles 
             to activate 
-pl,--projects <arg>     Comma-delimited list of specified 
             reactor projects to build instead 
             of all projects. A project can be 
             specified by [groupId]:artifactId 
             or by its relative path. 
-q,--quiet        Quiet output - only show errors 
-rf,--resume-from <arg>    Resume reactor from specified 
             project 
-s,--settings <arg>     Alternate path for the user 
             settings file 
-T,--threads <arg>      Thread count, for instance 2.0C 
             where C is core multiplied 
-t,--toolchains <arg>     Alternate path for the user 
             toolchains file 
-U,--update-snapshots     Forces a check for updated 
             releases and snapshots on remote 
             repositories 
-up,--update-plugins     Ineffective, only kept for 
             backward compatibility 
-V,--show-version      Display version information 
             WITHOUT stopping build 
-v,--version       Display version information 
-X,--debug        Produce execution debug output 
'cmd' is not recognized as an internal or external command, 
operable program or batch file. 
C:\Users\Babar>mvn -3.0.3 
Unable to parse command line options: Unrecognized option: -3.0.3 

usage: mvn [options] [<goal(s)>] [<phase(s)>] 

Options: 
-am,--also-make      If project list is specified, also 
             build projects required by the 
             list 
-amd,--also-make-dependents   If project list is specified, also 
             build projects that depend on 
             projects on the list 
-B,--batch-mode      Run in non-interactive (batch) 
             mode 
-C,--strict-checksums     Fail the build if checksums don't 
             match 
-c,--lax-checksums      Warn if checksums don't match 
-cpu,--check-plugin-updates   Ineffective, only kept for 
             backward compatibility 
-D,--define <arg>      Define a system property 
-e,--errors       Produce execution error messages 
-emp,--encrypt-master-password <arg> Encrypt master security password 
-ep,--encrypt-password <arg>   Encrypt server password 
-f,--file <arg>      Force the use of an alternate POM 
             file. 
-fae,--fail-at-end      Only fail the build afterwards; 
             allow all non-impacted builds to 
             continue 
-ff,--fail-fast      Stop at first failure in 
             reactorized builds 
-fn,--fail-never      NEVER fail the build, regardless 
             of project result 
-gs,--global-settings <arg>   Alternate path for the global 
             settings file 
-h,--help        Display help information 
-l,--log-file <arg>     Log file to where all build output 
             will go. 
-N,--non-recursive      Do not recurse into sub-projects 
-npr,--no-plugin-registry    Ineffective, only kept for 
             backward compatibility 
-npu,--no-plugin-updates    Ineffective, only kept for 
             backward compatibility 
-nsu,--no-snapshot-updates    Suppress SNAPSHOT updates 
-o,--offline       Work offline 
-P,--activate-profiles <arg>   Comma-delimited list of profiles 
             to activate 
-pl,--projects <arg>     Comma-delimited list of specified 
             reactor projects to build instead 
             of all projects. A project can be 
             specified by [groupId]:artifactId 
             or by its relative path. 
-q,--quiet        Quiet output - only show errors 
-rf,--resume-from <arg>    Resume reactor from specified 
             project 
-s,--settings <arg>     Alternate path for the user 
             settings file 
-T,--threads <arg>      Thread count, for instance 2.0C 
             where C is core multiplied 
-t,--toolchains <arg>     Alternate path for the user 
             toolchains file 
-U,--update-snapshots     Forces a check for updated 
             releases and snapshots on remote 
             repositories 
-up,--update-plugins     Ineffective, only kept for 
             backward compatibility 
-V,--show-version      Display version information 
             WITHOUT stopping build 
-v,--version       Display version information 
-X,--debug        Produce execution debug output 
'cmd' is not recognized as an internal or external command, 
operable program or batch file. 
C:\Users\Babar>mvn 3.0.3 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 4.179s 
[INFO] Finished at: Thu Nov 17 22:50:38 EET 2011 
[INFO] Final Memory: 1M/4M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] The goal you specified requires a project to execute but there is no POM 
in this directory (C:\Users\Babar). Please verify you invoked Maven from the co 
rrect directory. -> [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/MissingProject 
Exception 
'cmd' is not recognized as an internal or external command, 
operable program or batch file. 
C:\Users\Babar>mvn 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.637s 
[INFO] Finished at: Thu Nov 17 22:55:34 EET 2011 
[INFO] Final Memory: 1M/4M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] No goals have been specified for this build. You must specify a valid li 
fecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id 
>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are 
: validate, initialize, generate-sources, process-sources, generate-resources, p 
rocess-resources, compile, process-classes, generate-test-sources, process-test- 
sources, generate-test-resources, process-test-resources, test-compile, process- 
test-classes, test, prepare-package, package, pre-integration-test, integration- 
test, post-integration-test, verify, install, deploy, pre-clean, clean, post-cle 
an, pre-site, site, post-site, site-deploy. -> [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/NoGoalSpecifie 
dException 
'cmd' is not recognized as an internal or external command, 
operable program or batch file. 
C:\Users\Babar>mvn --3.0.3 
Unable to parse command line options: Unrecognized option: --3.0.3 

usage: mvn [options] [<goal(s)>] [<phase(s)>] 

Options: 
-am,--also-make      If project list is specified, also 
             build projects required by the 
             list 
-amd,--also-make-dependents   If project list is specified, also 
             build projects that depend on 
             projects on the list 
-B,--batch-mode      Run in non-interactive (batch) 
             mode 
-C,--strict-checksums     Fail the build if checksums don't 
             match 
-c,--lax-checksums      Warn if checksums don't match 
-cpu,--check-plugin-updates   Ineffective, only kept for 
             backward compatibility 
-D,--define <arg>      Define a system property 
-e,--errors       Produce execution error messages 
-emp,--encrypt-master-password <arg> Encrypt master security password 
-ep,--encrypt-password <arg>   Encrypt server password 
-f,--file <arg>      Force the use of an alternate POM 
             file. 
-fae,--fail-at-end      Only fail the build afterwards; 
             allow all non-impacted builds to 
             continue 
-ff,--fail-fast      Stop at first failure in 
             reactorized builds 
-fn,--fail-never      NEVER fail the build, regardless 
             of project result 
-gs,--global-settings <arg>   Alternate path for the global 
             settings file 
-h,--help        Display help information 
-l,--log-file <arg>     Log file to where all build output 
             will go. 
-N,--non-recursive      Do not recurse into sub-projects 
-npr,--no-plugin-registry    Ineffective, only kept for 
             backward compatibility 
-npu,--no-plugin-updates    Ineffective, only kept for 
             backward compatibility 
-nsu,--no-snapshot-updates    Suppress SNAPSHOT updates 
-o,--offline       Work offline 
-P,--activate-profiles <arg>   Comma-delimited list of profiles 
             to activate 
-pl,--projects <arg>     Comma-delimited list of specified 
             reactor projects to build instead 
             of all projects. A project can be 
             specified by [groupId]:artifactId 
             or by its relative path. 
-q,--quiet        Quiet output - only show errors 
-rf,--resume-from <arg>    Resume reactor from specified 
             project 
-s,--settings <arg>     Alternate path for the user 
             settings file 
-T,--threads <arg>      Thread count, for instance 2.0C 
             where C is core multiplied 
-t,--toolchains <arg>     Alternate path for the user 
             toolchains file 
-U,--update-snapshots     Forces a check for updated 
             releases and snapshots on remote 
             repositories 
-up,--update-plugins     Ineffective, only kept for 
             backward compatibility 
-V,--show-version      Display version information 
             WITHOUT stopping build 
-v,--version       Display version information 
-X,--debug        Produce execution debug output 
'cmd' is not recognized as an internal or external command, 
operable program or batch file. 

虽然教程中,我下面说应该打印出已安装的Maven的版本,例如:

Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100) 
Maven home: D:\apache-maven-3.0.3\bin\.. 
Java version: 1.6.0_25, vendor: Sun Microsystems Inc. 
Java home: E:\Program Files\Java\jdk1.6.0_25\jre 
Default locale: nl_NL, platform encoding: Cp1252 
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows" 

回答

0

尝试

mvn -version 

要使用maven easly,只需将其bin文件夹添加到PATH即可。

1

尝试mvn -vmvn --version

如可以看到的-v--version选项中使用参数(而不是版本号本身)。如果你看看你的打印输出的第一线,行家指的是一个未知的选项:

无法分析命令行选项:无法识别的选项:--3.0.3

0

--3.0.3不是一个有效的目标,因此它向您展示了所有可能的maven参数。

尝试:

mvn install 

这应该给你一个错误也是如此。但它应该开始下载一些文件。 此后,您的用户应该在其个人目录中有一个.m2文件夹。

+0

这有什么好处?我的意思是它将安装..... – enterprize

+0

其实你不会安装任何东西,因为你没有在当前文件夹中的pom.xml。但是之后你可以看到它是否构建你的本地存储库。 –