pom文件java tools.jar问题

时间:2017-05-27 14:29:34

标签: java maven pom.xml

我执行

mvn install

并收到以下错误:

[ERROR] Failed to execute goal on project 1: Could not resolve dependencies for project 1:1:jar:0.0.1-SNAPSHOT: Could not find artifact 
com.sun:tools:jar:1.6.0 at specified path C:\Program Files\Java\jdk1.7.0_21\lib -> [Help 1]

这就是我为tools.jar指定位置的方式:

<profiles>
<profile>
    <id>windows_profile</id>
    <activation>
        <activeByDefault>false</activeByDefault>
        <os>
            <family>windows</family>
        </os>
    </activation>
    <properties>
        <toolsjar>C:\Program Files\Java\jdk1.7.0_21\lib</toolsjar>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.6.0</version>
            <scope>system</scope>
            <systemPath>${toolsjar}</systemPath>
        </dependency>
    </dependencies>
</profile>
</profiles>

也许我应该在这里指定完整路径?

 <systemPath>${toolsjar}</systemPath>

1 个答案:

答案 0 :(得分:1)

您需要指定jar本身的路径,而不是指定包含jar的目录。

<properties>
    <toolsjar>C:\Program Files\Java\jdk1.7.0_21\lib</toolsjar>
</properties>

应该是

<properties>
    <toolsjar>C:\Program Files\Java\jdk1.7.0_21\lib\tools.jar</toolsjar>
</properties>