2011-06-08 95 views
1

我希望签声纳,所以我加了下面的代码片段到我的pom.xml的依赖部分是从http://maven.apache.org/general.html#tools-jar-dependency我的Maven配置有什么问题?

<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已添加到我的本地库。在调试模式行家给出了错误:

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) 
+0

是你的JAVA_HOME env var set?它指向JDK而不是JRE? – mindas 2011-06-08 16:02:49

+0

@mindas是的,JAVA_HOME是在mvn安装过程中设置的:install-file – stacker 2011-06-08 16:05:08

+0

你可能试着用-X param运行mvn。它过于冗长,但可能会导致一些线索。 – mindas 2011-06-08 16:22:46

回答

3

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

您可能没有指向Eclipse来当你开始了正确的JRE/JDK(这是你并不一定配置,而为Windows)中

1

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

<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> 

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

0

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

如果要更改的工具罐子路径$ {java.home} /lib/tools.jar并验证您的JAVA_HOME/lib存在的tools.jar文件,它应该工作。

There你可以找到相关的jira。