问题
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.
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:
- 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 directories
- src/main/groovy
- test/unit
- At the Libraries screen, go with the default gradle-wrapper option
- At the Modules screen go with the 3
- "Select project SDK..." I select my 1.8 JDK setup. There's no mention of Grails here.
- I see a "No Frameworks detected" message. Should I be able to configure Grails here?
- Select finish.
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.
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.
回答1:
I've had this issue before as well. The only way around it is to:
- Blow away the intellij project
- Import from Existing Sources
- Double click the build.gradle
- Ensure auto-import on gradle is set to false
Here's the IntelliJ issue related - https://youtrack.jetbrains.com/issue/IDEA-149513
来源:https://stackoverflow.com/questions/34981134/how-do-i-import-an-existing-grails-3-3-0-12-project-in-intellij-15