gpt4 book ai didi

Grails 2.2.0 应用程序的 Maven 构建因 JDK 1.7 : Could not find artifact com. sun :tools:jar:1. 6 而失败

转载 作者:行者123 更新时间:2023-12-02 13:49:13 25 4
gpt4 key购买 nike

(由于更新的问题/问题更新了问题标题,请参阅底部的更新说明!):

我有一个 Grails 2.2.0 项目,通过“grails create-pom com.mycompany”为其创建了 pom.xml。

pom.xml:http://pastebin.com/AVahZjZF

在不修改 pom.xml 的情况下,我使用 JDK 1.7 运行“mvn package”并在使用 JDK 1.6 时出现以下错误> 它会很好地工作。

$ java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

$ mvn -version
Apache Maven 3.0.3 (r1075438; 2011-03-01 01:31:09+0800)
Maven home: /usr/share/maven
Java version: 1.7.0_11, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.7.4", arch: "x86_64", family: "mac"

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home

$ mvn package
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.company:company-projectname:0.1 (/Users/myuser/Projects/com.company.web/pom.xml) has 2 errors
[ERROR] Unresolveable build extension: Plugin org.grails:grails-maven-plugin:2.2.0 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:1.6 at specified path /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/jre/bundle/Classes/classes.jar -> [Help 2]
[ERROR] Unknown packaging: grails-app @ line 8, column 16
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

我看到 grails-maven-plugin-2.2.0.pom 中的 java 版本设置为 1.6,因此我现在的问题是:如何使我的 grails 项目的 maven 构建与 JDK 1.7 一起工作?看起来好像在 maven-compiler-plugin 中设置了正确的源和目标级别(设置为 1.6)。

文件夹 ~/.m2/repository/grails-maven-plugin:

enter image description here

我的环境:

  • maven 3.0.3
  • Grails 2.2.0
  • GRAILS_HOME 设置为我的 Grails 目录
  • JAVA_HOME 设置为我的 JDK 1.7 文件夹
  • JDK 1.7.0_11

我的 pom.xml 中的相关 java 工具部分:

<profiles>
<profile>
<id>tools</id>
<activation>
<property>
<name>java.vendor</name>
<value>Sun Microsystems Inc.</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>

最佳答案

这似乎是一个已知问题,据报道仍在 Mac OS X 上的 Grails 2.2.0 中发生。

http://jira.grails.org/browse/MAVEN-186

关于Grails 2.2.0 应用程序的 Maven 构建因 JDK 1.7 : Could not find artifact com. sun :tools:jar:1. 6 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15037082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com