【问题标题】:Error pushing to Heroku when route is removed from Play Framework从 Play 框架中删除路由时推送到 Heroku 时出错
【发布时间】:2026-01-15 12:05:01
【问题描述】:

在我的提交中:

  • 删除了控制器类:com.fractalemagic.Crashes
  • 从 conf/routes 中删除了相关行

Heroku 构建日志:

-----> Play 2.x - Java app detected
-----> Installing OpenJDK 1.8...done
-----> Running: sbt compile stage
       OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
       Getting org.scala-sbt sbt 0.13.5 ...
       :: retrieving :: org.scala-sbt#boot-app
        confs: [default]
        44 artifacts copied, 0 already retrieved (13482kB/434ms)
       Getting Scala 2.10.4 (for sbt)...
       :: retrieving :: org.scala-sbt#boot-scala
        confs: [default]
        5 artifacts copied, 0 already retrieved (24459kB/193ms)
       [info] Loading project definition from /tmp/scala_buildpack_build_dir/project
       [info] Set current project to SomethingMagical (in build file:/tmp/scala_buildpack_build_dir/)
       [info] Compiling 6 Scala sources and 25 Java sources to /tmp/scala_buildpack_build_dir/target/scala-2.11/classes...
       [error] /tmp/scala_buildpack_build_dir/target/scala-2.11/src_managed/main/com/fractalemagic/routes.java:8: error: cannot find symbol
       [error] public static final com.fractalemagic.ReverseCrashes Crashes = new com.fractalemagic.ReverseCrashes();
       [error]                                      ^
       [error]   symbol:   class ReverseCrashes
       [error]   location: package com.fractalemagic
       [error] /tmp/scala_buildpack_build_dir/target/scala-2.11/src_managed/main/com/fractalemagic/routes.java:11: error: package com.fractalemagic.javascript does not exist
       [error] public static final com.fractalemagic.javascript.ReverseCrashes Crashes = new com.fractalemagic.javascript.ReverseCrashes();
       [error]                                                 ^
       [error] /tmp/scala_buildpack_build_dir/target/scala-2.11/src_managed/main/com/fractalemagic/routes.java:16: error: package com.fractalemagic.ref does not exist
       [error] public static final com.fractalemagic.ref.ReverseCrashes Crashes = new com.fractalemagic.ref.ReverseCrashes();
       [error]                                          ^
       [error] /tmp/scala_buildpack_build_dir/target/scala-2.11/src_managed/main/com/fractalemagic/routes.java:8: error: cannot find symbol
       [error] public static final com.fractalemagic.ReverseCrashes Crashes = new com.fractalemagic.ReverseCrashes();
       [error]                                                                                     ^
       [error]   symbol:   class ReverseCrashes
       [error]   location: package com.fractalemagic
       [error] /tmp/scala_buildpack_build_dir/target/scala-2.11/src_managed/main/com/fractalemagic/routes.java:11: error: package com.fractalemagic.javascript does not exist
       [error] public static final com.fractalemagic.javascript.ReverseCrashes Crashes = new com.fractalemagic.javascript.ReverseCrashes();
       [error]                                                                                                           ^
       [error] /tmp/scala_buildpack_build_dir/target/scala-2.11/src_managed/main/com/fractalemagic/routes.java:16: error: package com.fractalemagic.ref does not exist
       [error] public static final com.fractalemagic.ref.ReverseCrashes Crashes = new com.fractalemagic.ref.ReverseCrashes();
       [error]                                                                                             ^
       [error] Note: Some input files use or override a deprecated API.
       [error] Note: Recompile with -Xlint:deprecation for details.
       [error] Note: /tmp/scala_buildpack_build_dir/app/Global.java uses unchecked or unsafe operations.
       [error] Note: Recompile with -Xlint:unchecked for details.
       [error] 6 errors
       [error] (compile:compile) javac returned nonzero exit code
       [error] Total time: 22 s, completed Aug 2, 2014 8:46:52 PM
 !     Failed to build app with sbt

 !     Push rejected, failed to compile Play 2.x - Java app

我在尝试使用 Activator 在本地运行项目时确实遇到了同样的错误,但在我运行 activator clean 之后它运行良好。

我在构建日志中注意到 Heroku 只编译代码:

-----> Running: sbt compile stage

当根据:https://devcenter.heroku.com/articles/play-support#activation

它也应该干净。

撤消提交后,我能够成功推送到 Heroku。

【问题讨论】:

    标签: heroku playframework-2.3


    【解决方案1】:

    您链接的文档似乎有点过时了。您需要通过设置环境变量 SBT_CLEAN=true 来专门告诉 heroku 进行干净编译。

    如果您使用的是 heroku 工具带:

    heroku config:set SBT_CLEAN=true -a your-app-name
    

    Heroku Build Behavior

    【讨论】:

    • 谢谢!修复了它:)
    【解决方案2】:

    对我来说,我通过删除目标下的所有内容然后重新编译来解决问题。

    【讨论】: