Missing tools.jar in local repository breaks m2ecl

2020-02-08 05:34发布

The problem I'm experiencing is that eclipse can't resolve any of the dependencies of my project. This causes problems because even though the dependencies seem to work alright when coding (I get autocompletion) I still get a huge list of errors referring to missing artifacts.

When filtering these, I found the following:

The container 'Maven Dependencies' references non existing library '/home/[...]/.m2/repository/com/sun/tools/1.5.0/tools-1.5.0.jar'

It seems that this dependency was introduced by struts2, who have a profile set up as follows in their pom:

<dependency>
    <groupId>com.sun</groupId>
    <artifactId>tools</artifactId>
    <version>1.5.0</version>
    <scope>system</scope>
    <systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>

That systemPath resolves and so I don't see a reason why this would be causing trouble. In any case, is there a way to tell eclipse that this m2eclipse dependency is a system dependency that is not found in the local repository?

17条回答
Explosion°爆炸
2楼-- · 2020-02-08 06:29

For Mac users

[1] To find out where your VM is type this /usr/libexec/java_home

[2] vi ./Eclipse.app/Contents/MacOS/eclipse.ini

[3]
-vm
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/
-vmargs ........ ........

[4] In Eclipse , Update Maven

[5] Sing All is Well :-)

查看更多
The star\"
3楼-- · 2020-02-08 06:30

This dependency should work as expected. If in doubt, try the command line version of Maven because the Eclipse plugin is very brittle when it comes to dependency resolution.

Unlike other parts of Eclipse, it is unable to create even a partial classpath for the build if something is wrong with the POM, so the error could be something else.

If all else fails, try to install the file into your local repository, so you can see the next error.

查看更多
放荡不羁爱自由
4楼-- · 2020-02-08 06:30

This issue due to wrong java configuration. every IDE required full JDK pack. becuase tools.jar available inside JDK lib not jre lib

  1. go to control panel change environment path variable to C:\Program Files\Java\jdk1.8.0_31\jre\bin.

  2. change JAVA_HOME to C:\Program Files\Java\jdk1.8.0_31.

  3. open IDE(eclipse or STS) change JRE system library to C:\Program Files\Java\jdk1.8.0_31

then restart IDE. it will work

查看更多
够拽才男人
5楼-- · 2020-02-08 06:30

A hacky solution that worked for me:

If m2e is complaining that the following jar is not found in the Maven cache (you can find the bad path in the error log for the pom file, or in the "Java Build Path > Maven Dependencies" list):

${HOME}/.m2/repository/jdk/tools/jdk.tools/1.6/jdk.tools-1.6.pom

then try the following command (fill in JAVA_VERSION_HERE for an installed JDK, e.g. jdk1.8.0_191-amd64, then use the two path sections after .m2/repository/ above to determine the correct groupId, and replace 1.6 with whatever version m2e is complaining about -- it may or may not matter if the JDK you have installed matches the version m2e is complaining about):

mvn install:install-file -Dfile=/usr/java/JAVA_VERSION_HERE/lib/tools.jar \
    -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.6

This command copies tools.jar from your JDK and puts it into the Maven cache, also creating a pom.xml file for it so that it can be used by Maven.

查看更多
倾城 Initia
6楼-- · 2020-02-08 06:35

I read this and tried various things. What worked for me was this: I changed the windows --> preferences --> java --> installed JREs to point to the JDK instead. That solved this problem.

查看更多
登录 后发表回答