简体   繁体   中英

How to configure Grails for Netbeans?

I am trying to configure Grails in Netbeans.

  • Grails version:3.2
  • Netbeans: 8.2
  • JDK: 1.8
  • OS: Windows 10

I have install and configured environment path and other stuffs. I can create and run project from the Command Prompt. But I can not create project from netbeans.

Warning |
Unrecognized flag: non-interactive.
Error |
Specify an application name or use --inplace to create an application in the current directory

This error is showing, to create project from Netbeans. I can run the created project though. I have already added Groovy plugin.

How can I solve this problem?

I don't think you are doing anything incorrectly. I have an environment very similar to yours (Grails version: 3.3.2, Netbeans: 8.2, JDK: 8u151, OS: Windows 10) and I see the same error: Specify an application name or use --inplace...

This is a known issue with NetBeans 8.2 that has already been bug reported; see Bug 258407 - Error when creating a Grails 3.1.x project . The problem has been confirmed to exist in Grails releases 3.1.0 up to 3.1.4, but I see the same issue in 3.3.2, and there is no fix for NetBeans 8.2.

However, I successfully created a Groovy/Grails application using JDK 8u151 with a DEV release of NetBeans which you can download from here: http://bits.netbeans.org/download/trunk/nightly/latest/

Note the caveat that comes with using DEV releases of NetBeans:

These builds are still under development and could contain defects that lead to data loss. They are meant for evaluation of new features. As always, be sure to back up your changes if you use these builds on your production code.

As long as you can you can live with that situation, using a DEV release is your (only) solution for creating Grails 3.x applications in NetBeans.

One final point: unlike NetBeans 8.2, DEV releases of NetBeans support Java 9 as well as Java 8, but don't use Java 9 when creating a Groovy/Grails applications. It won't work for a completely unrelated reason.

I'm using Windows 8 and Grails 3.3.8, but the following worked for me:

  1. Create the project using system command line (I used instructions in this page: how to create grails project through windows command promt ).
  2. Import the project to Netbeans 8.2 by clicking on File > Open Project... and selecting the project folder.

This solution works for me (Mac OS)

1) Open de console inside Netbeans

2) Navigate to your GRAILS_HOME/bin

3) Type grails create-app [YOUR_NAME_APP] --profile=web (rest-api, etc)

4) The project must be created at GRAILS_HOME/bin/[YOUR_NAME_APP]

5) Do not try to import into Netbeans instead of it Open the project

6) Start coding!

You can move the folder GRAILS_HOME/bin/[YOUR_NAME_APP] to the Netbeans workspace before open the project.

FYI, I am using netbeans 9 and grails 3.3.8 (dont use 3.3.9, its broken), and it works like a dream. I can create domain classes etc. from the menus in netbeans, run, debug etc. THe only thing I had to do was manually install the grails plugin for netbeans, and configure my grails paths etc. The answer on how to set this up is here: how to open a grails 3.3 app in netbeans 9?

The only thing I cant get to work (and its a bit of a show stopper), is multi-module projects (ie a grails app which depends on a grails plugin). I can run them, but netbeans does not recognise any of the imports so there is no code completion and it shows all files are having errors. What a shame, as appart from this, netbeans has very good grails support.

Note, I always create projects on the command line, eg "grails create-app myapp ...", then simply use the open project menu in netbeans and it instantly recognises them as grails.

Ensure you have gradle plugin installed for netbeans. Then go to File -> Open Project.

You should see the project shown by netbeans as a gradle project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM