在Intellij中配置groovy SDK:每次构建项目时都必须重复这个吗?

jav*_*999 8 java sdk groovy intellij-idea

我在尝试编译我的应用程序时遇到错误Intellij:

错误:无法编译Groovy文件:没有为模块定义Groovy库

"Configure Groovy SDK"当Inteli提示时,我通过选择模块解决了这个问题.我使用了库org.codehaus.groovy:groovy-all:2.4.4,然后将此库添加dependency为模块.

问题是,每次我在Intellij中重新构建我的项目或"刷新gradle项目"时,我都必须再次"配置Groovy SDK".

如何设置项目以便每次都不必重新执行此步骤?

Sea*_*ean 8

将groovy-all添加为pom.xml中的依赖项(如果您使用的是maven)或build.gradle(用于gradle).否则每次刷新或同步时,intellij都会删除它找到的"额外"依赖关系.

<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>2.4.6</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)