问题描述
IntelliJ的网站上有关于创建新Grails项目的文档,但导入项目更加粗略,我无法让它为我工作。
There's documentation on IntelliJ's website for creating a new Grails project, but importing a project is more sketchy and I cannot get it to work for me.
如果我告诉IntelliJ导入一个新项目,并将其指向我的项目目录,它不会将其识别为Grails项目。项目导入后,我可以转到项目菜单,右键单击项目并转到添加框架支持...并选择Groovy,但IntelliJ仍然无法将我的项目识别为Grails项目。例如,使用新的Grails项目,运行菜单将包含一个用于运行应用程序的按钮,该按钮将使用与Grails同义的3杯图标进行装饰。我的导入项目无法实现。
If I tell IntelliJ to import a new project, and point it to my project directory, it does not recognize it as a Grails project. After the project imports, I can go to the Project menu, right click on the project and go to "add Framework support..." and select Groovy, but IntelliJ still does not recognize my project as a Grails project. For instance, with a new Grails project the run menu would contain a button for running the app that would be decorated with the 3-cups icon synonymous with Grails. I don't get that with my imported project.
以下是我到目前为止所采取的具体步骤:
Here are the precise steps I'm taking so far:
- 从我刚刚完成的新项目开始。这是一个项目,我可以使用grails compile手动构建。
- 打开IntellliJ 15 UE并选择导入项目
- 选择包含我的build.gradle文件和grails-app目录的顶级目录
- 选择从现有来源创建项目
- 默认项目名称/位置
- 选择找到的所有源目录。其中包括:
- Start with my fresh unimported project. This is a project and I can build manually using grails compile.
- Open IntellliJ 15 UE and select "Import Project"
- Select the top level directory containing my build.gradle file and grails-app directory
- Select Create project from existing sources
- Default project name/location
- Select all source directories that were found. These include:
- grails-app conf,controllers,domain,init,taglib目录
- src / main / groovy
- test / unit
- grails-app conf, controllers, domain, init, taglib directories
- src/main/groovy
- test/unit
此时我我在IntelliJ编辑器窗口中有一个没有构建的项目。我可以转到添加框架支持并启用对Groovy的支持,然后引用我的Grails SDK。但无论如何我觉得我不应该这样做。我认为IntelliJ应该能够检测我的Project类型和特性,而我只是没有正确配置它。
At this point I'm at the IntelliJ editor window with a project that doesn't build. I can go to "Add Frameworks Support" and enable support for Groovy and at that point reference my Grails SDK. But in any case I feel like I shouldn't have to do this. I think IntelliJ ought to be able to detect my Project type and characteristics and that I'm just not configuring it right.
但无论如何,我的项目仍然无法编译在IntelliJ里面。我必须通过控制台构建它。现在我的所有Java文件都没有位于src / main / groovy编译中。所有引用 org.springframework
的导入都会返回无法解析符号错误。
But regardless, my project still doesn't compile inside IntelliJ. I have to build it via the console. Right now none of my Java files located in src/main/groovy compile. All of the imports that references org.springframework
are coming back with the "cannot resolve symbol" error.
推荐答案
我之前也遇到过这个问题。唯一的方法是:
I've had this issue before as well. The only way around it is to:
- 吹掉intellij项目
- 从现有资源导入
- 双击build.gradle
- 确保gradle上的自动导入设置为false
- Blow away the intellij project
- Import from Existing Sources
- Double click the build.gradle
- Ensure auto-import on gradle is set to false
这是与IntelliJ相关的问题 -
Here's the IntelliJ issue related - https://youtrack.jetbrains.com/issue/IDEA-149513
这篇关于如何在IntelliJ 15中导入现有的Grails 3(3.0.12)项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!