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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33920766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 22:17:44  来源:igfitidea点击:

Configuring groovy SDK within Intellij: have to repeat this each time project is built?

javaintellij-ideagroovysdk

提问by java123999

I was getting an error when trying to compile my application within Intellij:

尝试在以下范围内编译我的应用程序时出现错误Intellij

Error:Cannot compile Groovy files: no Groovy library is defined for module

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

I solved this issue by selecting "Configure Groovy SDK"for the module, when prompted by Inteli. I used library org.codehaus.groovy:groovy-all:2.4.4, this then adds this library as a dependencyfor the module.

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

The issue is that each time I re-buildmy project or "refresh gradle projects"in Intellij I have to "Configure Groovy SDK" again.

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

How can I set up my project so that I don't have to re-dothis step each time?

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

采纳答案by Sean

add groovy-all as a dependency to in your pom.xml (if you're using maven) or your build.gradle (for gradle). Otherwise every time your refresh or sync, intellij will remove the "extra" dependency it finds.

将 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>