【问题标题】:Scala class from atmosphere-play not found in Java application在 Java 应用程序中找不到来自气氛播放的 Scala 类
【发布时间】:2016-07-13 15:31:09
【问题描述】:

我正在尝试将 Atmosphere 添加到一位同事创建的 Play!Java 项目。我正在使用 Play 2.5.4

作为第一步,我只是尝试添加聊天示例。我已经逐字复制了从氛围播放中传递的文档中的所有内容。

我的 build.sbt 包含以下依赖项(我也有氛围运行时,但这似乎不是必需的,实际上可能与氛围播放冲突)

libraryDependencies ++= Seq(
 // javaJdbc,
  cache,
  javaWs,
 ... unrelated stuff ...
  "org.atmosphere.client" % "javascript" % "2.3.2",
   "org.atmosphere" % "atmosphere-play" % "2.3.0"
)

在 Global.java 中(是的,我知道,但 Play 文档说您需要它来支持 onRouteRequest):

package controllers;

import org.atmosphere.play.AtmosphereCoordinator;
import play.Application;
import play.GlobalSettings;
import play.api.mvc.Handler;
import play.mvc.Http.RequestHeader;
import org.atmosphere.play.Router;
import controllers.Chat;

import static org.atmosphere.play.AtmosphereCoordinator.*;

public class Global extends GlobalSettings {

    @Override
    public void onStart(Application application) {
        instance().discover(Chat.class).ready();
    }

    @Override
    public void onStop(Application application) {
        instance().shutdown();
    }

    @Override
    public Handler onRouteRequest(RequestHeader request) {
        return Router.dispatch(request);
    }

}

当我编译时:

[coaster-ui] $ compile
[info] Updating {file:/stuff/web/react/}root...
[info] Resolving net.contentobjects.jnotify#jnotify;0.94-play-1 ...
[info] Done updating.
[info] Compiling 8 Scala sources and 9 Java sources to /stuff/web/react/target/scala-2.11/classes...
[error] /stuff/web/react/app/controllers/Global.java:14: error: cannot find symbol
[error] import org.atmosphere.play.Router;
[error]                           ^
[error]   symbol:   class Router
[error]   location: package org.atmosphere.play
[error] 1 error
[error] (compile:compile) javac returned nonzero exit code
[error] Total time: 6 s, completed Jul 13, 2016 11:22:07 AM
[coaster-ui] $ 

我觉得我一定错过了一些非常基本的东西,但似乎无法弄清楚它是什么。任何指针将不胜感激。

谢谢!

【问题讨论】:

标签: java scala playframework-2.0 atmosphere


【解决方案1】:

Scala org.atmosphere.play.Router 在 2.2.0 中被 AtmosphereHttpRequestHandler.scala 取代。

您可以尝试将 Atmosphere 降级到 2.1.0 以查看它是否可以与您现有的代码一起编译。聊天示例使用2.1.0-SNAPSHOT,如果您现有的来源基于此,这可能是混淆的来源。

【讨论】:

  • 我想使用最新版本的氛围播放,因为我需要它与 Play 2.5 一起使用。我在解释替换的文档中找不到任何内容,这会有所帮助!谢天谢地,我现在可以正常工作了。
猜你喜欢
  • 2016-08-08
  • 2012-01-05
  • 1970-01-01
  • 1970-01-01
  • 2014-10-12
  • 2019-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多