简体   繁体   English

如何在netbeans中使用Play Framework 2.0

[英]How do I use Play Framework 2.0 in netbeans

Play Framework 2.0 doesn't seem to have much / any support for Netbeans. Play Framework 2.0似乎没有太多/任何支持Netbeans。 I'm currently just using it as an editor (loading the files using the favorites tab), but it's a little frustrating that Netbeans doesn't recognise any of the libraries / api's. 我目前只是将它用作编辑器(使用收藏夹选项卡加载文件),但Netbeans无法识别任何库/ api有点令人沮丧。

This means that EVERYTHING is underlined in red. 这意味着一切都用红色下划线标出。

Trying to create a free-form project requires a build file, so I get stuck there too. 尝试创建一个自由格式的项目需要一个构建文件,所以我也被困在那里。

Any ideas appreciated... 任何想法赞赏......

  1. Create a play project as per normal way. 按照正常方式创建播放项目。
  2. From the play CLI select play eclipsify to create an eclipse project. 从播放CLI中选择play eclipsify来创建一个eclipse项目。
  3. From netbeans, select File > Import Project > Eclipse Project 从netbeans中,选择“ File > Import Project > Eclipse Project
  4. Select Import Projects Ignoring Dependencies 选择Import Projects Ignoring Dependencies
  5. In Project to Import , insert the root of your play application. Project to Import ,插入播放应用程序的根目录。
  6. In Destination Folder , also insert the root of your play application. Destination Folder插入播放应用程序的根目录。
  7. Press Finish . Finish

使用eclipse支持生成eclipse项目,然后将其导入NetBeans

NetBeans now has Native Support for Play Framework 2.3.x and above: http://nbpleasureplugin.com/documentation/installation.html No Command line needed at all. NetBeans现在具有Play Framework 2.3.x及更高版本的原生支持: http ://nbpleasureplugin.com/documentation/installation.html根本不需要命令行。

The most important features are: 最重要的功能是:

  • Create, run, debug and test your app directly in the IDE 直接在IDE中创建,运行,调试和测试您的应用程序
  • Routes files support (Syntax coloring, Syntax Error highlighting, Autocompletion, Code navigation, Show implementation code (without navigate to source), Hint to Create method when it doesn't exist, formatting, Mark occurrences) 路径文件支持(语法着色,语法错误突出显示,自动完成,代码导航,显示实现代码(无导航到源),提示创建方法时不存在,格式化,标记出现)
  • Scala Template support (Syntax coloring, Syntax Error highlighting, Autocompletion, Code navigation, Show implementation code (without navigate to source), formatting, Mark occurrences) Scala模板支持(语法着色,语法错误突出显示,自动完成,代码导航,显示实现代码(无导航到源),格式化,标记出现)
  • Dependency Management 依赖管理
  • Test Single File 测试单个文件
  • SBT file minimal support SBT文件最小支持
  • Configurations (Formatting indentation, syntax coloring, port to use, activator parameters, etc.) 配置(格式化缩进,语法着色,要使用的端口,激活器参数等)
  • Support play version from 2.3.x and above 支持2.3.x及以上版本的播放版本

Note: I created this plugin. 注意:我创建了这个插件。

Just want to tack on to these other responses. 只是想谈谈这些其他回应。 As this was the first google result for me when solving this problem. 因为这是解决此问题时我的第一个谷歌结果。 The current build of Play uses the 'eclipse' command instead of the 'eclipsify' command. Play的当前版本使用'eclipse'命令而不是'eclipsify'命令。 Also, it should be ran from the Play environment. 此外,它应该从Play环境运行。

Navigate to your project directory: 导航到您的项目目录:

Enter the Play environment: [projectdir] [username]$ play 进入播放环境: [projectdir] [username]$ play

Eclipsify the project: [projectname] $ eclipse Eclipsify项目: [projectname] $ eclipse

Then import in netbeans, following the top voted answers direction. 然后按照最高投票回答方向导入netbeans。

The following works for Play 2.4 and NetBeans 8.0.2. 以下适用于Play 2.4和NetBeans 8.0.2。 Posting here since this question shows up in search results regardless of Play version and the official documentation is too brief and does not provide specific steps. 在此处发布,因为此问题出现在搜索结果中,无论Play版本如何, 官方文档太简短,并且没有提供具体步骤。

Pre-requisites: activator (tested with 1.3.5), NetBeans with all scala-related available plugins installed (in my case this included nbscala mentioned in Play docs, but not nbsbt). 先决条件:激活器(使用1.3.5测试),NetBeans安装了所有与scala相关的可用插件(在我的情况下,这包括在Play文档中提到的nbscala,但不包括nbsbt)。

  1. Add nbsbt to your plugin definition file. 将nbsbt添加到插件定义文件中。 You can use either the global one at ~/.sbt/0.13/plugins/plugins.sbt or the project-specific one at PROJECT_DIR/project/plugins.sbt: 您可以使用〜/ .sbt / 0.13 / plugins / plugins.sbt中的全局变量或PROJECT_DIR / project / plugins.sbt中的项目特定变量:

    // for sbt 0.13.x addSbtPlugin("org.netbeans.nbsbt" % "nbsbt-plugin" % "1.1.4") // for sbt 0.12.x addSbtPlugin("org.netbeans.nbsbt" % "nbsbt-plugin" % "1.0.2")

    [from nbsbt README] Or else you can just create a separate netbeans.sbt file next to plugins.sbt and add to .gitignore if you prefer to separate IDE-specific config from the rest of the project. [来自nbsbt README]或者您可以在plugins.sbt旁边创建一个单独的netbeans.sbt文件,如果您希望将IDE特定的配置与项目的其余部分分开,则添加到.gitignore

  2. On command line go to the project root and run activator specifying that you want to create a netbeans configuration: 在命令行上转到项目根目录并运行激活器,指定要创建netbeans配置:

    $ cd PROJECT_DIR

    $ activator netbeans

    Running activator will first resolve all the dependencies (including nbsbt) and then create NetBeans files. 运行激活器将首先解析所有依赖项(包括nbsbt),然后创建NetBeans文件。 I you should see .classpath_nb file in the root as a result of this command. 我应该在root中看到.classpath_nb文件作为此命令的结果。

  3. Finally, just go to NetBeans and simply do File > Open Project... 最后,只需转到NetBeans,只需执行文件>打开项目...

There is no native support for Netbeans at this time . 有一个在这个时候没有Netbeans的原生支持。

Check Play 2.0 IDE documentation for Netbeans section. 查看Netbeans部分的Play 2.0 IDE文档

There are also some suggestions of workaround in the Google Groups topic Google网上论坛主题中也有一些变通方法的建议

Take a look at play2-maven-plugin which provides a nice mavenized interface to the Play/SBT/Ivy universe. 看看play2-maven-plugin ,它为Play / SBT / Ivy世界提供了一个漂亮的mavenized界面。 One small pom.xml then lets you leverage all of NetBeans' Maven goodness to get rid of those red underlines... 一个小的pom.xml然后让你利用所有NetBeans的Maven优点来摆脱那些红色的下划线......

只需使用命令: play netbeansify myApp

I was going through the same trouble a few days ago. 几天前我遇到了同样的麻烦。 What I found out is that NetBeans has a plugin in its plugins repository that is called Pleasure Plugin[ http://plugins.netbeans.org/plugin/61050 ] and is designed for NetBeans 8. 我发现NetBeans的插件库中有一个名为Pleasure Plugin [ http://plugins.netbeans.org/plugin/61050 ]的插件,专为NetBeans 8而设计。

This plugin is awesome because it opens the Play project and shows all the packages and folders divided as they should be. 这个插件非常棒,因为它打开了Play项目,并显示了应该分配的所有包和文件夹。 It allows you to execute the project, to debug the back-end easily (just put a break point and run the project in debug mode) among other features. 它允许您执行项目,轻松调试后端(只需设置断点并以调试模式运行项目)等功能。

The only problem is that this plugin has a Commercial License and you can use it for free for a 30 day trial. 唯一的问题是这个插件有商业许可证,您可以免费使用它进行为期30天的试用。

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

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