eclipse 缺少神器“sun.jdk:jconsole:jar:jdk”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33236195/
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
Missing artifact "sun.jdk:jconsole:jar:jdk"
提问by Steffi S.
When adding Arquillian to a Maven build I get the above exception in Eclipse:
将 Arquillian 添加到 Maven 构建时,我在 Eclipse 中遇到上述异常:
Missing artifact sun.jdk:jconsole:jar:jdk
缺少神器 sun.jdk:jconsole:jar:jdk
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.1.7.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-persistence-dbunit</artifactId>
<version>1.0.0.Alpha7</version>
</dependency>
(The message is not the problem, but that Eclipse refuses to compile the project because of it. Maven works, though.)
(该消息不是问题,而是 Eclipse 拒绝编译该项目。不过,Maven 可以工作。)
Naturally the first thing I did was trying to exclude it from the Maven dependencies (wildfly-arquillian-container-managed
is where the dependency tree states the dependency comes from):
自然,我做的第一件事就是尝试将它从 Maven 依赖项中排除(wildfly-arquillian-container-managed
是依赖项树声明依赖项来自的地方):
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<exclusions>
<exclusion>
<artifactId>jconsole</artifactId>
<groupId>sun.jdk</groupId>
</exclusion>
</exclusions>
</dependency>
There was no change. I tried to start Eclipse with -vm C:\Program Files\Java\jdk1.8.0_60\bin
. And tried to edit the JDK in "Preferences -> Installed JREs" to contain the JAR in the tools directory. But nothing works.
没有变化。我试图用-vm C:\Program Files\Java\jdk1.8.0_60\bin
. 并尝试在“首选项 -> 已安装的 JRE”中编辑 JDK,以将 JAR 包含在工具目录中。但没有任何效果。
What can I do?
我能做什么?
回答by Mateus Pegoraro
I put my dependencies like this and it works fine:
我把我的依赖项像这样,它工作正常:
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-embedded</artifactId>
<version>8.1.0.CR1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.15</version>
<scope>test</scope>
</dependency>
<!-- Arquillian -->
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-embedded</artifactId>
<version>8.1.0.CR1</version>
<exclusions>
<exclusion>
<groupId>sun.jdk</groupId>
<artifactId>jconsole</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
See that the exclusion tag is in the "wildfly-embedded" dependency...
看到排除标签在“wildfly-embedded”依赖项中......
Don't forget to command "mvn install" and click right button at project and "Maven Update", if it doesn't work try delete folder "~/.m2/repository" and download all the dependencies again.
不要忘记命令“mvn install”并在项目和“Maven Update”上单击右键,如果它不起作用,请尝试删除文件夹“~/.m2/repository”并再次下载所有依赖项。
回答by Olaf Kroh
Alastair, thanks for solving the problem. The cause lies in the the pom of the transient dependency org.wildfly:wildfly-cli (8.2.0.Final)
. There you can find the following dependency declaration:
Alastair,感谢您解决问题。原因在于瞬态依赖的 pom org.wildfly:wildfly-cli (8.2.0.Final)
。在那里您可以找到以下依赖项声明:
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>jconsole</artifactId>
<version>jdk</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/jconsole.jar</systemPath>
</dependency>
Actually, the jar is located in ${java.home}/lib/jconsole.jar
.
实际上,罐子位于${java.home}/lib/jconsole.jar
.
P.S.: The version is also insufficient. So, I deleted this version from my local maven repository.
PS:版本也不够。因此,我从本地 Maven 存储库中删除了此版本。
回答by BalusC
I faced this while working in a Windows machine. The project itself worked perfectly fine in my Ubuntu machine. However the project's build failed with exactly that message, induced by a transient org.wildfly:wildfly-ejb
dependency.
我在 Windows 机器上工作时遇到了这个问题。该项目本身在我的 Ubuntu 机器上运行得非常好。然而,由于暂时的org.wildfly:wildfly-ejb
依赖关系,该项目的构建失败了,并显示出该消息。
Missing artifact sun.jdk:jconsole:jar:jdk
缺少神器 sun.jdk:jconsole:jar:jdk
I didn't feel the project configuration needed to be changed as it's supposed to just work fine across all environments and thus the Windows environment itself must have been wrong. My first thought was that Eclipse itself is in some way using JRE instead of JDK.
我觉得不需要更改项目配置,因为它应该可以在所有环境中正常工作,因此 Windows 环境本身一定是错误的。我的第一个想法是 Eclipse 本身在某种程度上使用 JRE 而不是 JDK。
So I checked java -version
in CMD and it appears to point to a JRE installed somewhere in /Program Files
folder while I've always been manually installing JDKs in /Java
folder. Then I inspected the %PATH%
environment variable in Windows settings. It appears to include a /ProgramData/Oracle/Java/javapath
. That folder contained a few symlinks to the JRE in /Program Files
folder. That was thus actually being used to start Eclipse and run all its tasks. When I removed it (there was already a JDK/bin
further down in %PATH%
setting) and restarted Eclipse and re-executed Maven build, the error went away.
因此,我检查java -version
了 CMD,它似乎指向安装在/Program Files
文件夹中某处的 JRE,而我一直在/Java
文件夹中手动安装 JDK 。然后我检查了%PATH%
Windows 设置中的环境变量。它似乎包括一个/ProgramData/Oracle/Java/javapath
. 该文件夹包含一些指向文件夹中 JRE 的符号链接/Program Files
。因此,这实际上用于启动 Eclipse 并运行其所有任务。当我删除它(设置中已经有一个JDK/bin
进一步的下降%PATH%
)并重新启动 Eclipse 并重新执行 Maven 构建时,错误消失了。
No changes needed to pom.xml or Eclipse configuration. Just watch out with what's Windows all installing and updating for you in the background and check your %PATH%
if it still has JDK in top.
无需更改 pom.xml 或 Eclipse 配置。只需注意在后台为您安装和更新的所有 Windows 内容,并检查您的%PATH%
顶部是否仍有 JDK。
回答by peterh - Reinstate Monica
The reason of the problem is that the jconsole.jar
is part of the jdk, thus it is not distributed as an ordinary maven package.
问题的原因是jconsole.jar
jdk的一部分,因此它不是作为普通的maven包分发的。
Typically, project pom.xml
s insert this jconsole.jar
as a system package, i.e. it doesn't even try to download them from the central maven repo. Although it would be possible to distribute it also on this way.
通常,项目pom.xml
将其jconsole.jar
作为系统包插入,即它甚至不会尝试从中央 maven 存储库下载它们。虽然也可以通过这种方式分发它。
The simplest solution of the problem is to use a jdk which contains this jconsole.jar
.
该问题的最简单解决方案是使用包含 this 的 jdk jconsole.jar
。
Alternatively, you can download this jar from anywhere, only you have to make it reachable in the compilation classpath.
或者,您可以从任何地方下载此 jar,只需在编译类路径中使其可访问。
Or, you can also modify the pom.xml, or install the package manually into your local maven repo, as the other answers state.
或者,您也可以修改 pom.xml,或将软件包手动安装到本地 Maven 存储库中,如其他答案所述。
回答by Alastair Knowles
I spent the best part of a day fighting this problem. Simple solution is to manually install the missing jar from your jdk using maven, something like:
我花了一天中最好的时间来解决这个问题。简单的解决方案是使用 maven 从 jdk 手动安装缺少的 jar,例如:
c:\workspace\prism>mvn install:install-file -Dfile=C:\java\jdk\lib\jconsole.jar -DgroupId=sun.jdk -DartifactId=jconsole -Dversion=1.8 -Dpackaging=war.
c:\workspace\prism>mvn install:install-file -Dfile=C:\java\jdk\lib\jconsole.jar -DgroupId=sun.jdk -DartifactId=jconsole -Dversion=1.8 -Dpackaging=war。
Who knows why eclipse cannot do this ...
谁知道为什么eclipse不能这样做......
回答by tarilabs
Maybe is more of a workaround than a proper solution, anyway I solved this issue by removing the profile "activebydefault" in the pom. This way, Eclipse won't complain for the "Missing artifact sun.jdk:jconsole:jar:jdk" but the JUnit test won't run in Eclipse - as I use testing only from maven test, and not the Eclipse embedded JUnit runner, it just need to specify which profile ID you want to run against.
也许比适当的解决方案更像是一种解决方法,无论如何我通过删除 pom.xml 中的配置文件“activebydefault”解决了这个问题。这样,Eclipse 不会因为“缺少工件 sun.jdk:jconsole:jar:jdk”而抱怨,但 JUnit 测试不会在 Eclipse 中运行 - 因为我只使用来自 maven 测试的测试,而不是 Eclipse 嵌入式 JUnit 运行程序,它只需要指定您要针对哪个配置文件 ID 运行。
回答by Manjusha Nair
I was facing the same issue, but none of this was a perfect solution for me. Steps to solve :
我遇到了同样的问题,但对我来说这些都不是完美的解决方案。解决步骤:
- Check if you are pointing to the JDK location correctly : echo $JAVA_HOME
- Open pom.xml from IDE (mine is eclipse), select Dependency Hierarchy, and search for jconsole. If you see jconsole, it is because sometimes jconsole would be given as an interdependency and the path given could not be recognized. Excluding that jar will solve the issue.
- 检查您是否正确指向 JDK 位置: echo $JAVA_HOME
- 从IDE(我的是eclipse)打开pom.xml,选择Dependency Hierarchy,然后搜索jconsole。如果您看到 jconsole,那是因为有时 jconsole 会作为相互依赖项给出,并且无法识别给出的路径。排除那个 jar 将解决问题。
回答by jake kong
i was searched jdk full name. (cos i was used when startethe 1.8.0_191 but after change laptop. its also changed to 1.8.0_282) so i was searched at STS.
我被搜索jdk全名。(因为我在 startethe 1.8.0_191 时使用,但在更换笔记本电脑后。它也更改为 1.8.0_282)所以我在 STS 上被搜索。
there is a string(java path) at the .factorypath.
.factorypath 中有一个字符串(java 路径)。
so i change that.
所以我改变了。
its fixed now.
它现在固定。
guys try this way~
小伙伴们试试这个~