我的 Maven 配置出了什么问题?

发布于 2024-11-14 15:27:43 字数 2026 浏览 6 评论 0原文

我想检查声纳,所以我将以下代码片段添加到我的 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)

I want to checkout sonar, so I added the following snippet to my pom.xml the dependency part was taken from 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>

Unfortunatly the error persists

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

I also followed the suggestion to add the missing jar manually to the repository, which had no effect.

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

What am I doing wrong?

EDIT:

I verified that tools.jar has been added to my local repository. In debug mode maven shows the error:

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

好菇凉咱不稀罕他 2024-11-21 15:27:43

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

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

Are you running this in eclipse? If the answer is yes, this is an annoying and very misunderstood problem. Take a look at my answer here

You may not be pointing eclipse to the right jre/jdk when you're starting up (this is something you didn't necessarily configure rather was Windows)

偏爱你一生 2024-11-21 15:27:43

我曾经遇到的一个问题是 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>

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

A problem I had once was different location of tools.jar under Mac OS. Here's the profiles section to solve the problem:

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

However I am not sure this is something you're facing.

夜声 2024-11-21 15:27:43

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

如果将工具 jar 路径更改为 ${java.home}/lib/tools.jar 并验证 JAVA_HOME/lib 中是否存在 tools.jar 文件,它应该有效。

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

If your JAVA_HOME points to your jdk (e.g./usr/lib/jvm/jdk1.6.0_33), your tools.jar configuration (${java.home}/../lib/tools.jar) indicates that there should be a tools jar with the following path: /usr/lib/jvm/lib/tools.jar.

If you change the tools jar path to ${java.home}/lib/tools.jar and verify that in your JAVA_HOME/lib there is the tools.jar file, it should work.

There you can find the related jira.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文