简体   繁体   中英

How do I use Play Framework 2.0 in netbeans

Play Framework 2.0 doesn't seem to have much / any support for 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.

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.
  3. From netbeans, select File > Import Project > Eclipse Project
  4. Select Import Projects Ignoring Dependencies
  5. In Project to Import , insert the root of your play application.
  6. In Destination Folder , also insert the root of your play application.
  7. Press 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.

The most important features are:

  • Create, run, debug and test your app directly in the 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)
  • Dependency Management
  • Test Single File
  • SBT file minimal support
  • Configurations (Formatting indentation, syntax coloring, port to use, activator parameters, etc.)
  • Support play version from 2.3.x and above

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. Also, it should be ran from the Play environment.

Navigate to your project directory:

Enter the Play environment: [projectdir] [username]$ play

Eclipsify the project: [projectname] $ eclipse

Then import in netbeans, following the top voted answers direction.

The following works for Play 2.4 and 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.

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. Add nbsbt to your plugin definition file. 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:

    // 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.

  2. On command line go to the project root and run activator specifying that you want to create a netbeans configuration:

    $ cd PROJECT_DIR

    $ activator netbeans

    Running activator will first resolve all the dependencies (including nbsbt) and then create NetBeans files. I you should see .classpath_nb file in the root as a result of this command.

  3. Finally, just go to NetBeans and simply do File > Open Project...

There is no native support for Netbeans at this time .

Check Play 2.0 IDE documentation for Netbeans section.

There are also some suggestions of workaround in the Google Groups topic

Take a look at play2-maven-plugin which provides a nice mavenized interface to the Play/SBT/Ivy universe. One small pom.xml then lets you leverage all of NetBeans' Maven goodness to get rid of those red underlines...

只需使用命令: 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.

This plugin is awesome because it opens the Play project and shows all the packages and folders divided as they should be. 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.

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