简体   繁体   中英

play framework unable to run an existing project

I'm a rookie developer trying to run an application using play framework. I've followed the tutorial and can successfully create a new project.

However when I go to the directory that has the project I'm supposed to work on and enter the play command I get the following error:

[error] Not a valid command: play (similar: last, alias, loadp)
[error] Not a valid project ID: play
[error] Not a valid configuration: play
[error] Not a valid key: play (similar: clean)
[error] play

I have very little knowledge regarding the framework and don't know where to start correcting my mistake. Any suggestions ?

You have to run the play command this way:

./play cmd [app_path] [--options]

where in case of running a project, it is

./play run /path/to/projectname

I am facing this problem in the context of sub projects.

This is what worked for me.


Code:

import sbt._
import sbt.Keys._

object ApplicationBuild extends Build {

  val helloWorldProj = Project(id = "HelloWorld", base = file("helloworld"))    

  val appName = "WebApp"
  val appVersion = "1.0"
  val appDependencies = Seq()

  val webAppProj = PlayProject( appName, appVersion, appDependencies, path = file("webapp"), mainLang = PlayProject.SCALA)
    .dependsOn(helloWorldProj)
    .aggregate(helloWorldProj)

}

On running the play command, I get the following error:

Error:

[info] Set current project to HelloWorld (in build file:/D:/EclipseProjects/HelloWorldPlayMultiProject/)
[error] Not a valid command: play (similar: last, alias, loadp)
[error] Not a valid project ID: play
[error] Not a valid configuration: play
[error] Not a valid key: play (similar: play-hash, play-dist, play-conf)
[error] play
[error]     ^

Solution:

Now, if I rename helloWorldProj as zhelloWorldProj , it works! In this case, play sets the active project to WebApp .(Since webAppProj variable name alphabetically comes before zhelloWorldProj )

I can then change the active project to HelloWorld by giving the command project HelloWorld .

I think this has something to do with how sbt finds the Project objects using reflection.

I delete all directories in the project folder and it works. Do not delete files (build.properties, Build.scala and plugins.sbt)

需要有关于你的环境(操作系统,播放版本等)的更多细节,但是如果你得到的错误是游戏不是一个有效的命令,我的第一个行动方案是检查play.sh的路径(我假设你是使用非Windows)包含在您的系统路径中?

The problem was the version difference of play. The project I was suppose to work on was developed in play 1.2 where as I installed the version 2.0 .

By the way, working with 2.0 on a project developed by version 1.2 is possible, but I strongly recommend not to do it that way as there are problems on the later stages as well.

Depending on the language you're using, make sure one of the following is in your build.sbt file:
play.Project.playJavaSettings
play.Project.playScalaSettings

I also got the same problem! What happened was in my /user/xxx/project folder there were old projects from 1.x version. Deleting that folder worked for me!

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