如此简单,我正在尝试将此应用程序https://github.com/pac4j/spark-pac4j-demo部署到我的heroku实例。

我可以在本地运行:mvn compile exec:java

但是在heroku上,没有安装Maven:

2016-04-12T18:34:21.074629+00:00 heroku[web.1]: Starting process with command `mvn compile exec:java`
2016-04-12T18:34:23.303776+00:00 app[web.1]: bash: mvn: command not found
2016-04-12T18:34:23.303620+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.


我不知道如何设置每手所有的类路径。我会在这里有所帮助。

最佳答案

首先,您需要提供依赖项(即,将其复制到target/目录中)。您可以通过将其添加到pom.xml中来实现:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.4</version>
    <executions>
      <execution>
        <id>copy-dependencies</id>
        <phase>package</phase>
        <goals><goal>copy-dependencies</goal></goals>
      </execution>
    </executions>
  </plugin>


然后,运行该应用程序的正确命令可能类似于java -cp target/classes:target/dependency/* Main(其中Main应该替换为包含public static void main方法的类)。

这是一个sample app using Spark,因此您可以看到所有这些如何结合在一起。

Maven不是在生产环境中运行应用程序的好方法。它为您的应用程序创建了一个额外的依赖关系,并为流程执行添加了间接层。

09-25 22:23
查看更多