2014-04-27 53 views
0

我嘗試從播放2.1.1遷移Java Play框架項目。到2.2.0。我跟着遷移指南(https://www.playframework.com/documentation/2.2.0/Migration22),但在應用更改後得到以下編譯錯誤:編譯錯誤遷移播放2.1.1到2.2

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

我試着用類型安全的激活劑和播放命令編譯它,都不起作用。當我使用舊的播放版本時,編譯與兩種工具一起工作。

我想我錯過了一些依賴關係。例如。自新版本以來,我必須手動將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 

Build.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  
) 
} 

回答

1

阿卡版本播放2.2更改,因此你必須做出一些調整。

我沒有你的java代碼,所以我要用我的代碼來幫助你(我目前也在做一個遷移)。如果我的anwser沒有解決您的問題,請添加您的java代碼。

對於這兩種調度和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中成功遷移調度程序。