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

Mac上Java7的目标1.7mvn安装无效

龙博
2023-03-14

我下载了一个Github项目,我的团队将为它做开发工作(它是私有的,所以共享它没有帮助)。它包括一个具有以下依赖项的pom.xml文件:

 <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>2.3.2</version>
         <configuration>
              <source>1.7</source>
              <target>1.7</target>
             <showDeprecation>true</showDeprecation>
            <showWarnings>true</showWarnings>
         </configuration>
 </plugin>

这个项目依赖于Java7。在其他人的情况下研究这个问题--看起来他们的java和mvn版本以及JAVA_HOME环境变量不一致,所以让我向您展示一些终端输出:

Last login: Thu Jun  5 13:05:34 on console
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
$ mvn -version
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T12:37:52-05:00)
Maven home: /usr/local/apache-maven-3.2.1
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
$ javac -version
javac 1.7.0_60
sudo mvn clean install
[INFO] Compiling 239 source files to /usr/local/gardens/githubproject/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
javac: invalid target release: 1.7
Usage: javac <options> <source files>
use -help for a list of possible options

[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.793 s
[INFO] Finished at: 2014-06-05T13:08:38-05:00
[INFO] Final Memory: 26M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project hgtvgardens: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] javac: invalid target release: 1.7
[ERROR] Usage: javac <options> <source files>
[ERROR] use -help for a list of possible options
[ERROR] -> [Help 1]
[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/MojoFailureException

我最好的猜测是这是一个环境问题--但为什么会有问题,它会在哪里?

在研究中,其他人通过将tools.jar复制到/library/java/extensions/...中来解决他们的问题,我也这么做了--但没有结果。

为什么不为Mac安装Java来解决这些问题呢?因为除了在~/.bash_profile中设置JAVA_HOME之外,我还没有做太多自定义Java设置的工作

sudo rm /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/ /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

其他团队成员完全没有问题--相同的操作系统、硬件、Github项目和软件...有些不一样-我不确定是什么...

有人建议使用更更新的maven编译器。

从http://search.maven.org/#artifactdetailsorg.apache.maven.plugins.plugins下载了maven-compiler-plugin3.1maven-plugin,并将其复制到我的apache-maven/lib目录中(这完全是猜测)。然后我将pom.xml更新为使用3.1而不是2.3.2

[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile 
(default-compile) on project githubproject: Execution default-compile of goal 
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile failed: 
A required class was missing while executing 
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile: 
org/codehaus/plexus/compiler/util/scan/mapping/SuffixMapping

共有1个答案

仉峻
2023-03-14

我已经用从Sun直接下载的1.7完全替换了我的Mac OS Java。它确实需要对指向currentJDK的链接进行一些修修补补,但结果如下。希望这会有所帮助,因为您的Java安装似乎已经损坏:

哪个OS:

System Version: OS X 10.9.3 (13D65)
Kernel Version: Darwin 13.2.0

我有哪个java?它在哪里:

schroedinger:backend olegs$ javac -version
javac 1.7.0_40

schroedinger:backend olegs$ which javac
/usr/bin/javac
schroedinger:Versions olegs$ ls -la /usr/bin/javac
lrwxr-xr-x  1 root  wheel  75 31 Okt  2013 /usr/bin/javac -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac

schroedinger:Versions olegs$ pwd
/System/Library/Frameworks/JavaVM.framework/Versions
schroedinger:Versions olegs$ ls -la
total 64
drwxr-xr-x  11 root  wheel  374 31 Okt  2013 .
drwxr-xr-x  12 root  wheel  408 21 Apr 19:42 ..
lrwxr-xr-x   1 root  wheel   10 31 Okt  2013 1.4 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 31 Okt  2013 1.4.2 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 31 Okt  2013 1.5 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 31 Okt  2013 1.5.0 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 31 Okt  2013 1.6 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 31 Okt  2013 1.6.0 -> CurrentJDK
drwxr-xr-x   8 root  wheel  272 31 Okt  2013 1.7
lrwxr-xr-x   1 root  wheel    1 31 Okt  2013 Current -> 1.7
lrwxr-xr-x   1 root  wheel   59 31 Okt  2013 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents
schroedinger:backend olegs$ grep jdk.version pom.xml 
    <jdk.version>1.7</jdk.version>

...    
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>${jdk.version}</source>
                <target>${jdk.version}</target>
            </configuration>
schroedinger:backend olegs$ echo $JAVA_HOME
schroedinger:backend olegs$ which mvn
/usr/local/bin/mvn

schroedinger:backend olegs$ ls -la /usr/local/bin/mvn
lrwxr-xr-x  1 dev  staff  29 31 Okt  2013 /usr/local/bin/mvn -> ../Cellar/maven/3.0.5/bin/mvn

它编译吗?

schroedinger:backend olegs$ mvn clean install
[INFO] Scanning for projects...
[INFO]                                 
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.407s
[INFO] Finished at: Thu Jun 05 20:35:48 CEST 2014
 类似资料:
  • 我试图通过克隆repo在mac os 10.13上安装Multicorn。在我的机器上,但得到错误,我还安装了mac os 10.13的xcode。 我得到的错误: Python的版本是2.7 clang-wall-Wwiness-原型-Wpoint er-arith-Wdisonation-post-语句-Wfalse=vla-Wendif-标签-Wwiness-forment-属性-Wform

  • 在学习之前,我正在学习我希望从spring安装spring。我已经下载并解压了,我需要关于在哪里放置文件夹的帮助,这样我就可以开始在Mac上使用工作了。 我知道这是一个很小的问题,但我还没有找到这样的安装,大多数教程使用spring.io生成一个zip文件,或者使用maven完成安装。

  • 问题内容: 这是我的错误信息: 所以2.7找不到pygame。这是在新安装的python上,而且我可以进入其他模块(pyo,wx,numpy)。我已经重新安装了pygame并在相应的库文件夹中查看,但在任何地方都找不到pygame模块。重新安装不能解决此问题。有什么建议吗? 编辑:在回答问题时,我怎么安装pygame的,我从这里位于的.dmg安装http://www.pygame.org/down

  • 正在下载https://dl.google.com/android/repository/emulator-darwin_x64-7243153.zipnet。SocketException:连接重置警告:在准备Android模拟器的SDK包时出错:连接重置。“安装Android模拟器(修订版:30.5.4)”失败。 当我试图在我的macbook pro m1上安装android Studio时显

  • 问题内容: 我检查了我的pip3和python3版本: 在虚拟环境中,我目前正在使用: 作为标准方法,输出以下消息: 安装后使用第一种方法说明: 有什么问题 我可以下载其他软件包,例如numpy,但没有Tensorflow。(MacOS 10.13.4) 问题答案: 更新:1.13版引入了对Python 3.7的支持 1.13版本的最新候选版本带来了Python 3.7支持,特别是预编译的CPU轮

  • 问题内容: 我正在尝试安装matplotlib以在Mac OS X上的Python中绘制应用程序图形。当我运行“ python setup.py install”时,它给了我这样的错误负载:http : //pastebin.com/u7fL37ic。 快速摘要: 我使用MacPorts安装了freetype,我认为这可以解决问题,但是没有运气。给我和以前一样的错误。似乎找不到正确的freetyp