首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java用源代码1.7 (或7)构建失败

Java用源代码1.7 (或7)构建失败
EN

Stack Overflow用户
提问于 2014-06-25 22:06:57
回答 1查看 434关注 0票数 0

我正在将我的java 6代码升级到java 7,更新后的JAVA_HOME指向OSX10.9上的JDK1.7。代码还没有使用任何Java 7特性。

当我运行构建"mvn干净安装“时,生成中断,没有任何有用的错误消息。

构建通过source=1.6和target=1.6继承了,但是对于source=1.7 (或7)和target=1.7 (或7),失败了

代码语言:javascript
复制
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version> <!-- tried with 2.3.2 and 3.0... no luck -->
        <configuration>
          <source>7</source>
          <target>7</target>
          <compilerArgument>-Werror </compilerArgument>
          <fork>true</fork>
        </configuration>

Error Message:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.773 s
[INFO] Finished at: 2014-06-25T14:56:13-08:00
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------
[**ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project core: Compilation failure
[ERROR] Failure executing javac,  but could not parse the error:
[ERROR] 1 error
[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
EN

回答 1

Stack Overflow用户

发布于 2014-06-25 22:58:13

我猜用JDK1.7编译您的代码会产生警告,而用1.6编译则不会。由于您告诉编译器在遇到<compilerArgument>-Werror </compilerArgument>警告时直接退出,这正是它所要做的,这并不是非常友好的Maven。我猜Maven会吞下原来的警告,以显示javac进程意外退出的错误。

删除<compilerArgument>-Werror </compilerArgument>指令应该允许继续编译。您必须更好地处理编译器警告,而不是让编译器退出,比如查看/解析Maven输出。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24419402

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档