我试图在Windows 7上设置maven。我尝试了版本3.3.3和3.3.1,两者结果相同。我尝试使用JAVA_HOME和路径变量来更改jdk,但我得到了相同的结果 我是maven的新手,请原谅我的无知。
我从mvn.cmd脚本中注释掉了echo以尝试调试。
启动maven的java调用只显示java帮助消息,就好像命令无效一样。我做错了什么?
H:\>"C:\bin\jdk1.7.0_60\bin\java.exe" -classpath "c:\bin\apache-maven-3.3.1\bin\..\boot\plexus-classworlds-2.5.2.jar" "-Dclassworlds.conf=c:\bin\apache-maven-3.3.1\bin\..\bin\m2.conf" "-Dmaven.home=c:\bin\apache-maven-3.3.1\bin\.." "-Dmaven.multiModuleProjectDirectory=H:\" org.codehaus.plexus.classworlds.launcher.Launcher
H:\>mvn
H:\>if "H:\" == "" (set "HOME=H:\" )
H:\>if not "" == "" goto skipRcPre
H:\>if exist "H:\\mavenrc_pre.bat" call "H:\\mavenrc_pre.bat"
H:\>if exist "H:\\mavenrc_pre.cmd" call "H:\\mavenrc_pre.cmd"
H:\>set ERROR_CODE=0
H:\>if not "C:\bin\jdk1.7.0_60" == "" goto OkJHome
H:\>if exist "C:\bin\jdk1.7.0_60\bin\java.exe" goto chkMHome
H:\>if not "" == "" goto valMHome
H:\>SET "M2_HOME=c:\bin\apache-maven-3.3.1\bin\.."
H:\>if not "c:\bin\apache-maven-3.3.1\bin\.." == "" goto valMHome
H:\>if not "_." == "_\" goto checkMCmd
H:\>if exist "c:\bin\apache-maven-3.3.1\bin\..\bin\mvn.cmd" goto init
H:\>set MAVEN_CMD_LINE_ARGS=
H:\>set MAVEN_PROJECTBASEDIR=
H:\>IF NOT "" == "" goto endDetectBaseDir
H:\>set EXEC_DIR=H:\
H:\>set WDIR=H:\
H:\>IF EXIST "H:\"\.mvn goto baseDirFound
H:\>cd ..
H:\>IF "H:\" == "H:\" goto baseDirNotFound
H:\>set MAVEN_PROJECTBASEDIR=H:\
H:\>cd "H:\"
H:\>IF NOT EXIST "H:\\.mvn\jvm.config" goto endReadAdditionalConfig
H:\>SET MAVEN_JAVA_EXE="C:\bin\jdk1.7.0_60\bin\java.exe"
H:\>for %i in ("c:\bin\apache-maven-3.3.1\bin\.."\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%i"
H:\>set CLASSWORLDS_JAR="c:\bin\apache-maven-3.3.1\bin\..\boot\plexus-classworlds-2.5.2.jar"
H:\>set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
H:\>"C:\bin\jdk1.7.0_60\bin\java.exe" -classpath "c:\bin\apache-maven-3.3.1\bin\..\boot\plexus-classworlds-2.5.2.jar" "-Dclassworlds.conf=c:\bin\apache-maven-3.3.1\bin\..\bin\m2.conf" "-Dmaven.home=c:\bin\apache-maven-3.3.1\bin\.." "-Dmaven.multiModuleProjectDirectory=H:\" org.codehaus.plexus.classworlds.launcher.Launcher
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 <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
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[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
H:\>if ERRORLEVEL 1 goto error
H:\>set ERROR_CODE=1
H:\>if not "" == "" goto skipRcPost
H:\>if exist "H:\\mavenrc_post.bat" call "H:\\mavenrc_post.bat"
H:\>if exist "H:\\mavenrc_post.cmd" call "H:\\mavenrc_post.cmd"
H:\>if "" == "on" pause
H:\>if "" == "on" exit 1
H:\>exit /B 1
H:\>
答案 0 :(得分:2)
"-Dmaven.multiModuleProjectDirectory=H:\"
我的问题。显然,java.exe尝试取消转义字符串\"
。
java "-Dabc=xyz\" my.Dummy
为我产生同样的错误,而
java "-Dabc=xyz\\" my.Dummy
似乎有效。
如果您使用其他项目目录路径,请查看是否有变化,或尝试"-Dmaven.multiModuleProjectDirectory=H:\\"
。
%HOME%
是mvn查看的环境变量,因此您可能希望将其设置为其他值,或者""
以便maven使用默认路径%HOMEDRIVE%%HOMEPATH%
。