将Spring mvc网站部署到Heroku时,应用程序崩溃了

时间:2015-07-14 22:55:30

标签: java spring spring-mvc heroku

我正在尝试将我的spring mvc项目部署到Heroku,我收到以下错误:

2015-07-14T22:42:49.088312+00:00 heroku[web.1]: Process exited with status 1
2015-07-14T22:42:49.101203+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-14T22:43:31.905877+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hops.herokuapp.com request_id=befdaefa-cb1e-4560-a190-c532a339531b fwd="70.73.71.223" dyno= connect= service= status=503 bytes=
2015-07-14T22:43:32.769807+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hops.herokuapp.com request_id=c04566c1-7b09-4b45-8f64-497601415823 fwd="70.73.71.223" dyno= connect= service= status=503 bytes=

我试过运行heroku运行rails控制台,但它给了我以下错误:

Your version of git is 1.9.3. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
Running `rails console` attached to terminal... up, run.8780
bash: rails: command not found

这就是我的Procfile的样子:

web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war

我已按照本网站上的说明操作,但我不知道如何启动和运行我的网站。 https://devcenter.heroku.com/articles/getting-started-with-spring-mvc-hibernate#add-jetty-runner

是否有其他网站可以轻松部署我的网站,或者有人知道如何解决此错误。任何帮助将非常感激。

更新

当运行foreman start web时,它显示以下输出:

started with pid 7510
17:18:59 web.1  | Error: Unable to access jarfile target/dependency/jetty-runner.jar
17:18:59 web.1  | exited with code 1
17:18:59 system | sending SIGTERM to all processes

pom.xml中显示的jetty依赖关系如下:

<dependency>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-runner</artifactId>
            <version>8.1.16.v20140903</version>
        </dependency>
    </dependencies>

我不知道如何解决这个问题,或者为什么它甚至会造成这个错误。

1 个答案:

答案 0 :(得分:0)

重复评论中的内容,以便将其标记为已回答。

您需要添加以下插件配置:

  <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</goal></goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-runner</artifactId>
                        <version>9.2.7.v20150116</version>
                        <destFileName>jetty-runner.jar</destFileName>
                    </artifactItem>
                </artifactItems>
            </configuration>
      </execution>
    </executions>
  </plugin>

这会将jetty-runner复制到slug中,以便在运行时使用。