Intellij:无法在“添加框架支持”中选择“Groovy”

Mic*_*ihs 7 ide groovy frameworks intellij-idea

我想在 Intellij Idea 2018.1 中为我的项目添加 Groovy 支持。但是当我从项目上下文菜单中打开“添加框架支持...”时,我在框架列表中看不到“Groovy”:

在此处输入图片说明

我在我的机器上安装了 Groovy 并将其配置为 IntelliJ 中的全局库:

在此处输入图片说明

不确定这是否可行,但我也无法将 Groovy 添加为 SDK:

在此处输入图片说明

我添加了 Groovy 作为模块依赖项:

在此处输入图片说明

我的根本问题是 IntelliJ 不能正确识别 Groovy 代码,例如我得到

Cannot resolve symbol `String`
Run Code Online (Sandbox Code Playgroud)

当我使用String课程时:

在此处输入图片说明

关于如何将 Groovy 作为框架和 SDK 提供的任何提示?

解决方案

感谢 CrazyCoder 将我指向损坏的 JDK。修复 JDK 并将 Groovy 添加为模块依赖项解决了该问题。请参阅https://www.jetbrains.com/help/idea/creating-and-managing-modules.html

Mai*_*cio 1

确保您的 JDK 配置正确。正如 @crazycoder 评论的那样,OP 是红色的,表示路径可能不正确。

Groovy 可以作为 Intellij 中的模块或库添加,或者在其依赖文件(pom.xml、build.gradle 等)中添加依赖项

1.模块(Intellij 中)

文件 > 项目结构Ctrl+Alt+Shift+S> 单击模块 > 依赖项。

Intellij 模块依赖

2. 库(Intellij 中):

转到File> Project Structure...> Libraries> 单击最左侧的加号 > 根据您的选择添加 Groovy jar 或 maven 源

Intellij:项目结构菜单

3.依赖(build.gradle):

group 'com.test'
version '1.0.0'

apply plugin: 'groovy'

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.codehaus.groovy:groovy:2.4.5"
}
Run Code Online (Sandbox Code Playgroud)