我在windows中输入了mvn命令,但命令行返回了一个java提示
我的机器上安装了maven 3.3.1和java 1.7,Windows 8.1。
MAVEN_HOME=C:\Program Files\Apache\apache-maven-3.3.1 JAVA_HOME=C:\Program Files\Java\jdk1.7.0_75 Path=%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%MAVEN_HOME%\bin;
我试过访问mvn命令行,在C:\ Users \ {myusername}>下,它运行良好:
C:\Users\{myusername}>java -version java version "1.7.0_75" Java(TM) SE Runtime Environment (build 1.7.0_75-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode) C:\Users\{myusername}>mvn -version Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T13:10:2 7-07:00) Maven home: C:\Program Files\Apache\apache-maven-3.3.1\bin\.. Java version: 1.7.0_75, vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.7.0_75\jre Default locale: en_US, platform encoding: GBK OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"
但当我将命令路径更改为D:,我的机器中的另一个磁盘时,输出变为:
D:\>mvn --version Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -server to select the "server" VM -hotspot is a synonym for the "server" VM [deprecated] The default VM is server. -cp -classpath A ; separated list of directories, JAR archives, and ZIP archives to search for class files. -D= set a system property -verbose:[class|gc|jni] enable verbose output -version print product version and exit -version: require the specified version to run -showversion print product version and continue -jre-restrict-search | -no-jre-restrict-search include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea[:...|:] -enableassertions[:...|:] enable assertions with specified granularity -da[:...|:] -disableassertions[:...|:] disable assertions with specified granularity -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:[=] load native agent library , eg -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:[=] load native agent library by full pathname -javaagent:[=] load Java programming language agent, see java.lang.instrument -splash: show splash screen with specified image See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m ore details. D:\>java -version java version "1.7.0_75" Java(TM) SE Runtime Environment (build 1.7.0_75-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
此外,当我使用Intellij创建maven项目时,就像quickstart一样,发生了类似的错误:
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.[ERROR] Maven execution terminated abnormally (exit code 1)
我试过像mvn -version,mvn -d。 但他们仍然无法工作。 有人可以帮忙吗? 谢谢!!
更新:现在我的环境变量设置为:
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_75; CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; M2_HOME=C:\Program Files\Apache\apache-maven-3.3.1; MAVEN_HOME=C:\Program Files\Apache\apache-maven-3.3.1; PATH=%JAVA_HOME%\bin;%M2_HOME%\bin;{others...}
问题仍然存在。
更新:
每当我在D:path中输入mvn命令后,命令行就会返回java提示; 似乎忽略了mvn之后的所有事情。 像这样:
D:\>mvn fewadsfe Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -server to select the "server" VM -hotspot is a synonym for the "server" VM [deprecated] The default VM is server. -cp -classpath A ; separated list of directories, JAR archives, and ZIP archives to search for class files. -D= set a system property -verbose:[class|gc|jni] enable verbose output -version print product version and exit -version: require the specified version to run -showversion print product version and continue -jre-restrict-search | -no-jre-restrict-search include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea[:...|:] -enableassertions[:...|:] enable assertions with specified granularity -da[:...|:] -disableassertions[:...|:] disable assertions with specified granularity -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:[=] load native agent library , eg -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:[=] load native agent library by full pathname -javaagent:[=] load Java programming language agent, see java.lang.instrument -splash: show splash screen with specified image See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m ore details.
我在Maven 3.3.1中遇到了同样的问题,但是当我尝试3.2.5时,问题就解决了。 我不知道Windows 7/8和maven 3.3.1有什么问题。
我也有maven 3.3.1和Windows 7的这个问题,我在论坛中找到了这个答案 。 在此版本的maven中,在驱动器的根目录(c:\,d:\,…)中发出命令行存在问题。 在任何其他目录上发出命令有效。
如前面的回复中所述,问题在于"-Dmaven.multiModuleProjectDirectory=C:\"
属性。 如果删除了此属性的引号,则java命令可以正常工作。 由于前面的反斜杠,似乎最终引用被视为路径的一部分。
在mvn.cmd
之后添加以下行:endDetectBaseDir
标记为我修复了它。 我正在使用maven 3.3.3。
IF "%MAVEN_PROJECTBASEDIR:~-1%"=="\" set MAVEN_PROJECTBASEDIR=%MAVEN_PROJECTBASEDIR%\
在另一个驱动器上,您正在运行命令--
而不是-
无法识别并打印-help
。 确保你正在使用
mvn -version
-Dmaven.multiModuleProjectDirectory系统属性未设置。
这是一个已知错误( 此处有更多详细信息),现已修复 。 按照错误跟踪器中的说明更新或修补当前安装。
在IDEA 14.0.x和14.1分支中已修复,该修复程序将分别在14.0.5和14.1.1中提供。
如果您想立即尝试修复,请执行以下操作:
对于IDEA 14.0.3 :
- 使用IDEA-137783-patch-for_IDEA_14.0.3.zip中的补丁解压缩存档
备份并更换以下jar子
- \插件\行家\ LIB \ maven.jar
- \插件\行家\ LIB \ Maven的服务器api.jar文件
与存档中的jar子
对于IDEA 14.1 :
- 使用IDEA-137783-patch-for_IDEA_14.1.zip中的补丁解压缩存档
备份并更换以下jar子
- \插件\行家\ LIB \ maven.jar
- \插件\行家\ LIB \ Maven的服务器api.jar文件
- \插件\行家\ LIB \ maven32服务器-impl.jar中
与存档中的jar子