我的 Maven 配置出了什么问题?
我想检查声纳,所以我将以下代码片段添加到我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你在 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)
我曾经遇到的一个问题是 Mac OS 下
tools.jar
的位置不同。这是解决问题的配置文件部分:但是我不确定这是否是您面临的问题。
A problem I had once was different location of
tools.jar
under Mac OS. Here's the profiles section to solve the problem:However I am not sure this is something you're facing.
如果您的 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.