【问题标题】:Intellij IDEA - Compile grails project with -source 1.8 (or 1.7)Intellij IDEA - 使用 -source 1.8(或 1.7)编译 grails 项目
【发布时间】:2014-12-10 00:27:43
【问题描述】:

在 Intellij 中运行 run-app 时,groovy 编译器报错:

(...)
.Error 
|
Compilation error: startup failed:
Compile error during compilation with javac.
(...).java:42: error: multi-catch statement is not supported in -source 1.6
        } catch (ParserConfigurationException | SAXException | IOException e) {
                                              ^
  (use -source 7 or higher to enable multi-catch statement)
1 error


1 error

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
(...)

我已经尝试了所有我发现或阅读的可能会影响它的设置:

  • 项目设置 -> 模块 -> 依赖项
  • 项目设置 -> 模块 -> 源
  • 项目设置 -> 项目
  • 项目设置 -> SDK
  • 设置 -> 编译器 -> Java 编译器
  • BuildConfig.groovy
  • pom.xml
  • 运行配置

我还能尝试什么?

【问题讨论】:

  • 您是否也检查过grails.project.(target|source).level 中的BuildConfig.groovy
  • @cfrick 太棒了,这就是工作!谢谢!将其推广为答案以获得学分:)。

标签: grails groovy intellij-idea javac


【解决方案1】:

BuildConfig.groovy 中也是目标/源级别的设置。据我了解,它们是设置它的唯一权限(好吧,起始 JDK 应该能够处理它)。

grails.project.target.level = 1.8
grails.project.source.level = 1.8

在新的 grails 项目中默认生成这两个值(至少从 2.X 开始)

【讨论】:

    猜你喜欢
    • 2013-09-28
    • 2014-09-24
    • 2019-12-07
    • 1970-01-01
    • 2012-03-14
    • 1970-01-01
    • 1970-01-01
    • 2020-10-23
    相关资源
    最近更新 更多