我对play框架(scala)是个新手,而且我还在使用我的第一个web应用程序。我刚刚在我的控制器中创建了第一个方法index:
def index = UserAwareContextAction { implicit request =>
val subset = request.params.get("subset").getOrElse("all")
request.user match {
case Some(user) => selectIndex(request, subset)
case _ => Ok(views.h
在sbt中,为了在保存时运行测试,我执行"~test“。当我想在保存时运行应用程序时,我会使用"~ run“。当我想要先运行测试,然后在保存时运行应用程序时,我该怎么办?
我尝试了"~ all test run",但它给了我一个错误
> ~ all test run
[error] Cannot mix input tasks with plain tasks/settings. Input task(s):
[error] ScopedKey(Scope(Select(ProjectRef(file:/home/johnreed/sbt
当从path运行命令时,激活器在创建新项目时失败
nschejtman@nschejtman-Lenovo-V570:~/projects$ activator new
Fetching the latest list of templates...
Browse the list of templates: http://typesafe.com/activator/templates
Choose from these featured templates or enter a template name:
1) minimal-akka-java-seed
2) minimal
我在PlayFramework中使用Guice,但我得到运行时错误:
Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) Could not find a suitable constructor in controllers.DirectUserController. Classes must have either one (and only one) constructor annotated with @Inject or a zero-a
我在Play Scala项目的application.conf中有secret key。
# See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
application.secret="........"
如何在我的控制器或服务中使用它?
我尝试了application.secret,它给我错误的value secret is not a member of controllers.Application。WIth play.crypto.secret
我正在开发一个使用ReactiveMongo的Scala play2.6应用程序。我遵循了默认play2.6安装( Play -scala-seed.g8)的示例,通过创建一个新实例来测试我的ProjectController,但我得到了一个NullPointerException。
这是我的控制器:
class ProjectController @Inject()(
cc: ControllerComponents,
val reactiveMongoApi: ReactiveMongoApi
)(implicit ec: ExecutionContext) e
我需要一些帮助,在IDEA中打开一个游戏项目。
我有所有的插件(Scala,Play支持,Play 2.0...)安装好了,当我打开一个新项目时,一切都解决得很好。
但是,如果我打开一个由Play创建的项目,用gen-idea或play idea创建.idea文件,我得到以下错误:
Play2:
You have useless source roots which may corrupt resolve for play 2 framework in your project:
/.../target/scala-2.10/src_managed/ma
我在Java中使用Play Framework2.2.3。
我只是在我的环球课程中添加了一个常量:
public static final String VERSION = play.application().configuration().getString("application.version");
然后我得到了这个错误:
play.api.PlayException: Cannot init the Global object[null]
at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultG
试图使用play框架访问oracle DataSource时出现以下错误:
sbt.PlayExceptions$CompilationException: Compilation error[You do not have an implicit Application in scope. If you want to bring
the current running Application into context, just add import play.api.Play.current]
build.properties:
sbt.version=0.12.2
db.default
当我尝试在Scala的Play 2.6中测试一个控制器时,我得到了一个空指针异常。这是对OK响应的测试:
class ApplicationControllerSpec extends PlaySpec
with MockitoSugar with ScalaFutures {
val mockOrchestrator = mock[ApplicationOrchestrator]
val mockCC = mock[ControllerComponents]
val controller = new ApplicationController(mockOrchestrator,
我使用IntelliJ IDEA创建了一个新的Play Framework 2应用程序。我在默认项目中更改的唯一事情是创建一个Java控制器Application,而不是默认的Scala控制器(称为相同的),并将Akka添加到项目中。
下面是我的build.sbt构建的样子:
import play.Project._
name := "ServerSide"
version := "1.0"
// the following line was added
libraryDependencies += "com.typesafe.akka"
我知道在讨论中有很多这样的链接,但要么它们与旧框架版本有关,要么它们对我不起作用,
我想要做的是将会话传递给scala模板,而不必显式地传递它们形成控制器,我没有在play 2.3.x版本中找到隐式参数的示例(工作),我的视图被呈现为ok(welcome.render(msg)),在我的模板中我正在执行@(notice: String)(implicit session: play.api.mvc.Session),但它给了我method render in class welcome cannot be applied to given types;错误,我也尝试了
@(notice: St
在启动play服务器时,我们得到了异常“配置位置不能为空”,有人能让我知道出了什么问题吗?
异常
Starting gpp-web at port 9000... ERROR
java.lang.IllegalArgumentException: Config locations must not be null
at org.springframework.util.Assert.noNullElements(Assert.java:241)
at org.springframewo
我到处找了看,但答案都没有用。下面是堆栈跟踪:
! @7832lo6ll - Internal server error, for (GET) [/] ->
play.api.UnexpectedException: Unexpected exception[ProvisionException: Unable to provision, see the following errors:
1) Could not find a suitable constructor in controllers.FileCtrl. Classes must have either one (an
我想知道是否可以用以下语法绑定依赖关系:
bind [Environment[User, Authenticator]] to FakeEnvironment[User, SessionAuthenticator](testUser)
(这是从测试中获得的,模块中的实际绑定略长一些)
其中具有以下签名:
case class SessionAuthenticator(val loginInfo : com.mohiva.play.silhouette.api.LoginInfo, ...)
extends scala.AnyRef
with com.mohiva.pl
我正在尝试从java 6升级到7。在Java 6中一切正常。但当我使用Java 7时,play显示以下错误
Cannot register class [models.ActivityMetrics] in Ebean server
In conf/dev.conf at line 43.
41
42 evolutionplugin=disabled
43 ebean.default = "models.*" <<<<<<<<<<<<<<<<<<<<<