1

我想检查声纳,所以我将以下片段添加到我的 pom.xml 中,依赖部分取自http://maven.apache.org/general.html#tools-jar-dependency

<profile>
     <id>sonar</id>
     <activation>
        <activeByDefault>true</activeByDefault>
     </activation>
     <properties>
       <sonar.jdbc.url>jdbc:derby://localhost:1527/sonar;create=true</sonar.jdbc.url>
       <sonar.jdbc.driverClassName>org.apache.derby.jdbc.ClientDriver
       </sonar.jdbc.driverClassName>
       <sonar.jdbc.username>sonar</sonar.jdbc.username>
       <sonar.jdbc.password>sonar</sonar.jdbc.password>
       <sonar.host.url>http://localhost:8080/sonar</sonar.host.url>
     </properties>
     <dependencies>
    <dependency>
    <groupId>com.sun</groupId>
    <artifactId>tools</artifactId>
    <version>1.4.2</version>
    <scope>system</scope>
    <systemPath>${java.home}/../lib/tools.jar</systemPath>
    </dependency>
      </dependencies>
</profile>

不幸的是,错误仍然存​​在

Embedded error: Missing:
----------
1) com.sun:tools:jar:1.4.2

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file

我还按照建议手动将缺少的 jar 添加到存储库中,但没有任何效果。

mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=$JAVA_HOME/lib/tools.jar

我究竟做错了什么?

编辑:

我确认 tools.jar 已添加到我的本地存储库中。在调试模式下,maven 显示错误:

1 required artifact is missing.

for artifact: 
  group:artifact:war:1.0.0-BUILD-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)
4

3 回答 3

3

你在eclipse中运行这个吗?如果答案是肯定的,那么这是一个令人讨厌且非常容易被误解的问题。看看我的回答here

启动时,您可能没有将 eclipse 指向正确的 jre/jdk(这是您不一定要配置的东西,而是 Windows)

于 2011-06-08T23:49:56.040 回答
1

我曾经遇到的一个问题是tools.jar在 Mac OS 下的不同位置。这是解决问题的配置文件部分:

<profiles>
    <profile>
        <id>java-home-parent-lib-tools-jar</id>
        <activation>
            <activeByDefault>false</activeByDefault>
            <file>
                <exists>${java.home}/../lib/tools.jar</exists>
            </file>
        </activation>
        <dependencies>
            <dependency>
                <groupId>sun.jdk</groupId>
                <artifactId>tools</artifactId>
                <version>1.5.0</version>
                <scope>system</scope>
                <systemPath>${java.home}/../lib/tools.jar</systemPath>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>java-home-parent-classes-classes-jar</id>
        <activation>
            <activeByDefault>false</activeByDefault>
            <file>
                <exists>${java.home}/../Classes/classes.jar</exists>
            </file>
        </activation>
        <dependencies>
            <dependency>
                <groupId>sun.jdk</groupId>
                <artifactId>tools</artifactId>
                <version>1.5.0</version>
                <scope>system</scope>
                <systemPath>${java.home}/../Classes/classes.jar</systemPath>
            </dependency>
        </dependencies>
    </profile>
</profiles>

但是,我不确定这是您面临的问题。

于 2011-06-08T18:05:03.380 回答
0

如果您的 JAVA_HOME 指向您的 jdk(例如/usr/lib/jvm/jdk1.6.0_33),则您的tools.jar配置(${java.home}/../lib/tools.jar)表明应该有一个具有以下路径的工具 jar/usr/lib/jvm/lib/tools.jar:.

如果您将工具 jar 路径更改为 ${java.home}/lib/tools.jar 并验证您的文件中JAVA_HOME/libtools.jar文件,它应该可以工作。

在那里你可以找到相关的jira。

于 2012-08-23T20:53:08.007 回答