当前位置: 首页 > 知识库问答 >
问题:

Maven build for Grails 2.2.0应用程序在JDK 1.7中失败:找不到工件com。sun:tools:jar:1.6

呼延晋
2023-03-14

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

我有一个Grails2.2.0项目,创建了pom。通过“grails-create-pom-com”为其创建xml。我的公司”。

波姆。xml:http://pastebin.com/AVahZjZF

没有修改pom。xml,我在JDK1.7中运行“mvn package”,并得到下面的错误,而在JDK1.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中的java版本设置为1.6。pom,因此我现在的问题是:如何让maven build for my grails项目与JDK 1.7一起工作?看起来maven编译器插件(设置为1.6)中设置了正确的源代码和目标级别。

文件夹~/。m2/存储库/grails maven插件:

我的环境:

  • Maven 3.0.3
  • Grails 2.2.0
  • GRAILS_HOME设置到我的Grails目录
  • JAVA_HOME设置到我的JDK 1.7文件夹
  • JDK 1.70_11

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

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

共有3个答案

刘辰钊
2023-03-14

问题是grails-maven-plugin说它需要JDK6中的一些东西:

tail -n20 ~/.m2/repository/org/grails/grails-maven-plugin/2.0.3/grails-maven-plugin-2.0.3.pom
    <profile>
        <id>jdk_mac</id>
        <activation>
            <os>
                <family>mac</family>
            </os>
        </activation>
        <dependencies>
            <dependency>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>
                <version>1.6</version>
                <scope>system</scope>
                <systemPath>${java.home}/bundle/Classes/classes.jar</systemPath>
            </dependency>
        </dependencies>
    </profile>
</profiles>

解决方案是复制JDK6类。jar到当前的JDK中。幸运的是,JDK7使用了不同的目录结构,因此不应该有任何冲突。

sudo mkdir -p /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/bundle/Classes
sudo cp /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/classes.jar /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/bundle/Classes/
司徒高寒
2023-03-14

使现代化

正如@Mathias提到的,这是Grails Maven插件中的一个bug。Grails 2.2.1中的问题已经解决,所有工作都很好。

我绝对可以使用mvn包在这里与Grails 2.2.0从Homebrew,*GRAILS_HOME*unset。

我的配置是OSX上的Maven 3.0.3和Grails 2.2.0。

我毫不费力地创建了一个“空白”的香草应用程序,并将其打包。

grails create-app stf && cd stf
grails create-pom com.rimerosolutions.grails
mvn package

在我的pom里。grails maven插件的版本设置为${grails.version}。

我在运行OSX,看起来你也在运行它。

  • 您使用的是私有的maven存储库吗?如果是这样,请尝试仔细检查那里的grails-maven-plugin工件。
  • 如果没有,只是尝试清除你的~/. m2/存储库中grails-maven-plugin. rm-rf特定的插件缓存的内容。
法烨华
2023-03-14

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

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

 类似资料:
  • 我已经安装了JDK1.7,我需要制作一个JavaWebStart应用程序。我在网上搜索了一下,发现你需要jnlp。jar在您的项目构建路径中。 还有一个类似的问题(http://stackoverflow.com/questions/7593029/where-can-i-download-jnlp-jar)用户说它在jdk文件夹中,特别是在C:\Program Files\Java\jdk1中。

  • 希望你能帮我解决这个问题。我正在苦读Heroku'Getting Start with Python‘页面,在该页面上安装必要的依赖项,以便在本地运行应用程序。直到最后一步,即运行命令为止,它都工作得很好。我运行它,然后运行下一个命令,这就是我得到这个错误的地方: 我不明白为什么我会得到这个错误。有人能帮我弄明白吗? 我的requirements.txt版本:

  • 行动: 考虑在配置中定义一个名为entityManagerFactory的bean。 下面是代码。应用JAVA 主控制器。JAVA AppUser。JAVA 用户存储库。JAVA 波姆。xml application.properties

  • 我已经为使用外部Tomcat的Spring Boot应用程序的JNDI数据源连接进行了bellow提到的配置。 context.xml类似 为spring boot定义了Application.Properties 更新了web.xml,如

  • 当我在WebSphere8.5.5中启动应用程序时,我得到了一个错误,并且应用程序启动失败,我搜索日志并得到了这个堆栈跟踪。你们知道吗?

  • 昨天,我的应用程序在上运行得很完美,但今天,当我开始使用我的应用程序并运行它时,我却不断收到错误消息 安装失败,出现消息“未能建立会话”。 屏幕: 单击“确定”获得错误消息 会话“app”:安装apk时出错 并且设备中不存在(已卸载)应用程序。请建议我怎么做?