简体   繁体   English

如何为Netbeans配置Grails?

[英]How to configure Grails for Netbeans?

I am trying to configure Grails in Netbeans. 我正在尝试在Netbeans中配置Grails。

  • Grails version:3.2 Grails版本:3.2
  • Netbeans: 8.2 Netbeans:8.2
  • JDK: 1.8 JDK:1.8
  • OS: Windows 10 作业系统: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. 但是我不能从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. 从Netbeans创建项目显示此错误。 I can run the created project though. 我可以运行创建的项目。 I have already added Groovy plugin. 我已经添加了Groovy插件。

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... 我的环境与您的环境非常相似(Grails版本:3.3.2,Netbeans:8.2,JDK:8u151,OS:Windows 10),并且看到相同的错误: 指定应用程序名称或使用--inplace ...

This is a known issue with NetBeans 8.2 that has already been bug reported; 这是NetBeans 8.2的已知问题,已经报告了错误。 see Bug 258407 - Error when creating a Grails 3.1.x project . 请参阅错误258407-创建Grails 3.1.x项目时出错 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. 已经确认该问题存在于Grails 3.1.0到3.1.4之前的版本中,但是在3.3.2中看到了相同的问题,并且没有针对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/ 但是,我使用JDK 8u151和NetBeans的DEV版本成功创建了Groovy / Grails应用程序,您可以从此处下载: http : //bits.netbeans.org/download/trunk/nightly/latest/

Note the caveat that comes with using DEV releases of NetBeans: 请注意使用NetBeans的DEV版本附带的警告:

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. 只要可以,您就可以使用DEV版本作为在NetBeans中创建Grails 3.x应用程序的(唯一)解决方案。

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. 最后一点:与NetBeans 8.2不同,NetBeans的DEV版本支持Java 9和Java 8,但是在创建Groovy / Grails应用程序时不使用Java 9。 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: 我正在使用Windows 8和Grails 3.3.8,但是以下方法对我有用:

  1. Create the project using system command line (I used instructions in this page: how to create grails project through windows command promt ). 使用系统命令行创建项目(我使用了此页中的说明: 如何通过Windows命令promt创建grails项目 )。
  2. Import the project to Netbeans 8.2 by clicking on File > Open Project... and selecting the project folder. 通过单击文件>打开项目...,然后选择项目文件夹,将项目导入Netbeans 8.2。

This solution works for me (Mac OS) 该解决方案适用于我(Mac OS)

1) Open de console inside Netbeans 1)在Netbeans中打开de console

2) Navigate to your GRAILS_HOME/bin 2)浏览至您的GRAILS_HOME / bin

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

4) The project must be created at GRAILS_HOME/bin/[YOUR_NAME_APP] 4)必须在GRAILS_HOME / bin / [YOUR_NAME_APP]中创建项目

5) Do not try to import into Netbeans instead of it Open the project 5)不要尝试导入Netbeans而不是将其打开打开项目

6) Start coding! 6)开始编码!

You can move the folder GRAILS_HOME/bin/[YOUR_NAME_APP] to the Netbeans workspace before open the project. 您可以在打开项目之前将文件夹GRAILS_HOME / bin / [YOUR_NAME_APP]移至Netbeans工作区。

FYI, I am using netbeans 9 and grails 3.3.8 (dont use 3.3.9, its broken), and it works like a dream. 仅供参考,我使用的是netbeans 9和grails 3.3.8(不要使用3.3.9,它已损坏),它的工作就像一个梦。 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? 我可以从netbeans的菜单中创建域类等,然后运行,调试等。我唯一要做的就是手动为netbeans安装grails插件,并配置grails路径等。如何设置此问题的答案是此处: 如何在netbeans 9中打开grails 3.3应用程序?

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). 我唯一无法工作的东西(以及一点点的显示障碍)是多模块项目(即,依赖于grails插件的grails应用)。 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. 我可以运行它们,但是netbeans无法识别任何导入,因此没有代码完成,它显示所有文件都有错误。 What a shame, as appart from this, netbeans has very good grails support. 令人遗憾的是,netbeans具有很好的grails支持。

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. 注意,我总是在命令行上创建项目,例如“ grails create-app myapp ...”,然后仅使用netbeans中的打开项目菜单,它立即将它们识别为grails。

Ensure you have gradle plugin installed for netbeans. 确保为netbeans安装了gradle插件。 Then go to File -> Open Project. 然后转到文件->打开项目。

You should see the project shown by netbeans as a gradle project. 您应该看到netbeans显示的项目为gradle项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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