【问题标题】:Compilation Error Migration Play 2.1.1 to 2.2编译错误迁移播放 2.1.1 到 2.2
【发布时间】:2014-04-27 18:24:41
【问题描述】:

我尝试从 play 2.1.1 迁移 Java play 框架项目。到 2.2.0。我遵循了迁移指南 (https://www.playframework.com/documentation/2.2.0/Migration22),但在应用更改后出现以下编译错误:

.../Global.java:38: cannot find symbol
symbol  : method schedule(scala.concurrent.duration.FiniteDuration,
              scala.concurrent.duration.FiniteDuration,akka.actor.ActorRef,
              parser.ParserActor.MensaName,scala.concurrent.ExecutionContext)
location: interface akka.actor.Scheduler
                .schedule(Duration.create(diff, TimeUnit.MILLISECONDS),
                ^
.../controllers/Parsers.java:24: cannot find symbol
symbol  : method scheduleOnce(scala.concurrent.duration.FiniteDuration,akka.actor.ActorRef,parser.ParserActor.MensaName,scala.concurrent.ExecutionContext)
location: interface akka.actor.Scheduler
                .scheduleOnce(Duration.create(0, TimeUnit.SECONDS),
                ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
(compile:compile) javac returned nonzero exit code

我尝试用 typesafe-activator 和 play 命令编译它,都不起作用。当我使用旧的播放版本时,编译适用于这两种工具。

我想我在某些地方缺少依赖项。例如。自新版本以来,我是否必须手动将 Akka 添加到依赖项中?还是我监督了其他一些常见错误?

plugins.sbt

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0")

build.properties

sbt.version=0.13.0

构建.scala

    import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {

  val appName         = "mensa-server"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,
    javaCore,
    javaJdbc,
    javaEbean,
    "org.jsoup" % "jsoup" % "1.7.2",
    "net.sf.flexjson" % "flexjson" % "3.0",
    "postgresql" % "postgresql" % "9.1-901.jdbc4",
    "org.apache.commons" % "commons-lang3" % "3.1",
    "com.typesafe" %% "play-plugins-mailer" % "2.1.0",
    "org.apache.pdfbox" % "pdfbox" % "1.8.2"
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    // Add your own project settings here      
  )
}

【问题讨论】:

    标签: playframework akka typesafe-activator


    【解决方案1】:

    Akka 版本在 Play 2.2 中发生了变化,因此您必须进行一些调整。

    我没有您的 java 代码,所以我将使用我的代码来帮助您(我目前也在进行迁移)。如果我的 anwser 没有解决您的问题,请添加您的 java 代码。

    对于 scheduler 和 scheduleOnce,在这个新版本中,您必须添加一个 ExecutionContext,您可以将Akka.system().dispatcher() 作为参数

    例如,之前:

    Akka.system().scheduler()
                 .scheduleOnce(Duration.create(1, TimeUnit.SECONDS),
                     new Runnable() {
                         @Override
                         public void run() {
                             video.process(action);
                         }
                     });
    

    之后:

    Akka.system().scheduler()
                 .scheduleOnce(Duration.create(1, TimeUnit.SECONDS),
                     new Runnable() {
                         @Override
                         public void run() {
                             video.process(action);
                         }
                     }, 
                     Akka.system().dispatcher());
    

    如果您想了解更多信息:http://www.playframework.com/documentation/2.2.x/JavaAkka

    我不确定这是否会对您有所帮助,但这是我在 2.2 中成功迁移调度程序所必须做的唯一更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-05
      • 2020-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-14
      相关资源
      最近更新 更多