eclipse Workspace 定义了一个不包含有效 jre/lib/rt.jar 的 VM:C:\Program Files\Java\jre7
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11473488/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Workspace defines a VM that does not contain a valid jre/lib/rt.jar: C:\Program Files\Java\jre7
提问by KItis
I am new to maven and i have been creating simple web application with maven using hibernate, spring etc. i get following error occur when i run mvn eclipse:eclipse
command.
我是 maven 的新手,我一直在使用 hibernate、spring 等使用 maven 创建简单的 Web 应用程序mvn eclipse:eclipse
。运行命令时出现以下错误。
[WARNING] Workspace defines a VM that does not contain a valid jre/lib/rt.jar: C:\Program Files\Java\jre7
[WARNING] could not read workspace project:c:\Users\Acer\workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\myproject
org.codehaus.plexus.util.xml.pull.XmlPullParserException: processing instruction can not have PITarget with reserveld xml name (position: START_D
OCUMENT seen \r\n<?xml ... @2:7)
at org.codehaus.plexus.util.xml.pull.MXParser.parsePI(MXParser.java:2453)
at org.codehaus.plexus.util.xml.pull.MXParser.parseProlog(MXParser.java:1447)
at org.codehaus.plexus.util.xml.pull.MXParser.nextImpl(MXParser.java:1395)
at org.codehaus.plexus.util.xml.pull.MXParser.next(MXParser.java:1093)
at org.codehaus.plexus.util.xml.Xpp3DomBuilder.build(Xpp3DomBuilder.java:187)
at org.codehaus.plexus.util.xml.Xpp3DomBuilder.build(Xpp3DomBuilder.java:83)
at org.codehaus.plexus.util.xml.Xpp3DomBuilder.build(Xpp3DomBuilder.java:48)
at org.apache.maven.plugin.eclipse.reader.ReadWorkspaceLocations.readArtefact(ReadWorkspaceLocations.java:341)
at org.apache.maven.plugin.eclipse.reader.ReadWorkspaceLocations.readWorkspace(ReadWorkspaceLocations.java:536)
at org.apache.maven.plugin.eclipse.reader.ReadWorkspaceLocations.init(ReadWorkspaceLocations.java:94)
at org.apache.maven.plugin.eclipse.EclipsePlugin.getWorkspaceConfiguration(EclipsePlugin.java:2063)
at org.apache.maven.plugin.eclipse.EclipsePlugin.fillDefaultClasspathContainers(EclipsePlugin.java:1580)
at org.apache.maven.plugin.eclipse.EclipsePlugin.setup(EclipsePlugin.java:978)
at org.apache.maven.plugin.ide.AbstractIdeSupportMojo.execute(AbstractIdeSupportMojo.java:500)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[INFO] no substring wtp server match.
this is my pom.xml
这是我的pom.xml
could anybody tell me what i am doing wrong here. thanks in advance for any help
谁能告诉我我在这里做错了什么。提前感谢您的帮助
采纳答案by om39a
I looks like a java issue. Check your java_home directory. Is it pointing to C:\Program Files\Java\jre7 ? If so let maven also point to read same location by configure the toolchains.xml in your maven directory (e.g D:\maven-2.2.1\conf) to your java version
我看起来像一个java问题。检查您的 java_home 目录。它指向 C:\Program Files\Java\jre7 吗?如果是这样,让 maven 也通过将 maven 目录(例如 D:\maven-2.2.1\conf)中的 toolchains.xml 配置为你的 java 版本来指向读取相同的位置
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.7</version> <!--This should be same as is configured via the toolchains plugin -->
<vendor>ibm</vendor> <!--This should be same as is configured via the toolchains plugin -->
</provides>
<configuration>
<jdkHome>C:\Program Files\Java\jdk1.7.0</jdkHome>
</configuration>
</toolchain>
</toolchains>
回答by Reg Whitton
I was also getting the error:
我也收到错误:
[WARNING] Workspace defines a VM that does not contain a valid jre/lib/rt.jar: C:\Program Files\Java\jre6
[警告] Workspace 定义的 VM 不包含有效的 jre/lib/rt.jar:C:\Program Files\Java\jre6
but I don't get the
但我不明白
[WARNING] could not read workspace project:c:\Users\Acer\workspace.metadata.plugins\org.eclipse.core.resources.projects\myproject
[警告] 无法读取工作区项目:c:\Users\Acer\workspace.metadata.plugins\org.eclipse.core.resources.projects\myproject
(perhaps you were not setting your workspace path up correctly on the mvn command line by using the option -Declipse.workspace=...)
(也许您没有使用选项 -Declipse.workspace=... 在 mvn 命令行上正确设置工作区路径)
Anyway, the first warning was caused by me using a JDK in a non-standard place (JAVA_HOME=C:\tools\java\jdk1.6.0_31) and setting my Eclipse workspace up to use that as the default. The Maven Eclipse plugin does not seem to choose the default JDK correctly, The "mvn eclipse:eclipse" would not work until I removed the JDK in "C:\Program Files\Java\jre6" from the list of installed JDKs within Eclipse. I only have the correct one in the list now.
无论如何,第一个警告是由我在非标准位置 (JAVA_HOME=C:\tools\java\jdk1.6.0_31) 中使用 JDK 并将我的 Eclipse 工作区设置为默认值引起的。Maven Eclipse 插件似乎没有正确选择默认 JDK,直到我从 Eclipse 中已安装的 JDK 列表中删除了“C:\Program Files\Java\jre6”中的 JDK,“mvn eclipse:eclipse”才会工作。我现在列表中只有正确的一个。
回答by KeSyren
Add your own JRE, remove the default JRE installed in Eclipse. Yeah, it works.I could get no warning information when typing the command mvn eclipse:eclipse.
添加您自己的JRE,删除Eclipse 中安装的默认JRE。是的,它有效。我在输入命令 mvn eclipse:eclipse 时没有得到警告信息。
回答by Jo?o
Try to store your maven projects in a directory that is not your eclipse workspace then import the projects to eclipse (without copying it!). Now the mvn eclipse:eclipse should work without warnings.
尝试将您的 Maven 项目存储在不是您的 eclipse 工作区的目录中,然后将项目导入 eclipse(不要复制它!)。现在 mvn eclipse:eclipse 应该可以正常工作了。
回答by Ivan Popivanov
Seems to me maven fails to parse Eclipse's workspace settings properly. I was hitting the warning, and then I removed all JREs (I had two JREs and one JDK under Window-Preferences-Java-Installed JREs) and left only the JDK. No warnings since.
在我看来,Maven 无法正确解析 Eclipse 的工作区设置。我遇到了警告,然后我删除了所有 JRE(我在 Window-Preferences-Java-Installed JRE 下有两个 JRE 和一个 JDK),只留下了 JDK。从那以后没有警告。