我有一个由子项目组成的游戏项目,我在Heroku上使用。我正在使用Play 2.3和Scala 2.11.4
目标
方法
我的方法是将项目罐“发布”到Maven,然后运送一个只使用已发布工件的项目。这适用于我的机器,但是当我将它部署到Heroku时,它无法编译:它无法找到'controllers.ReverseXXX'。
我的实际应用程序现在有数千个文件,但我已经设法用github上的一个小得多的项目重新创建了这个问题。我正在部署到本地自包含的maven存储库,以简化此问题的重复。重新创建问题所需的两个项目是https://github.com/stave-escura/mainChildPlayApp和https://github.com/stave-escura/deploy
重现问题的步骤
git clone https://github.com/stave-escura/mainChildPlayApp.git
cd mainChildPlayApp
git clone https://github.com/stave-escura/deploy.git
sbt
>publish
>run
{At this point if you go to localhost:9000 you should see Main Hello world and localhost:9000/child should produce Child Hello World}
{terminate the run with Ctrl-d}
exit
cd deploy
sbt
>run
{At this point if you go to localhost:9000 you should see Main Hello world and localhost:9000/child should produce Child Hello World}
{terminate the run with Ctrl-d}
>exit
heroku git:remote -a <put in here the git repository details for your heroku app>
git add --all :/
git commit -m "Initial Commit"
git push --force heroku master
即使项目在本地工作(由运行检查),它也会在Heroku上失败并显示
等消息 [error] /tmp/scala_buildpack_build_dir/target/scala-2.11/src_managed/main/controllers/routes.java:16: error: package controllers.ref does not exist
[error] public static final controllers.ref.ReverseApplication Application = new controllers.ref.ReverseApplication();
发生了什么:
我的项目目录是
Project
app
...
conf
...
public
...
deploy
modules
child
conf
public
main
conf
public
在发布期间,我制作了一个SBT插件来复制conf和公共目录以进行部署(合并它们),并且我也将maven工件发布到deploy下的子目录中。因此,发布后的部署结构变为
Project
...
Deploy
Conf
Public
Maven
我在deploy目录中的sbt看起来像这样
organization := "org.myorg"
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.4"
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "Local" at new File("maven").toURI.toURL+"snapshots"
libraryDependencies += "org.myorg" %% "proj" % "1.0-SNAPSHOT"
lazy val deployedWebsite = (project in file(".")).enablePlugins(PlayScala)
它是发送到Heroku的deploy目录中的git存储库。
声明
我设法按照这些说明在我的机器上复制错误。如果他们不适合你(指示错误,或者你得到不同的结果),请告诉我。像这样复杂的报道问题!
答案 0 :(得分:1)
最佳解决方案是sbt-heroku plugin。这是Heroku的支持。它还没有很好地处理子项目,但有希望很快修复and open issue for sub project。