【问题标题】:App crashes when deploying spring mvc website to Heroku将 spring mvc 网站部署到 Heroku 时应用程序崩溃
【发布时间】:2015-10-03 19:23:47
【问题描述】:

我正在尝试将我的 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 run 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

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

更新

当运行工头启动 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 中显示的码头的依赖关系如下:

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

我不知道如何准确地解决这个问题,也不知道为什么它甚至会产生这个错误。

【问题讨论】:

  • 您的应用程序日志说什么?使用heroku logs --source app 进行过滤。此外,如果您没有运行 Ruby on Rails 应用程序,rails console 将无法使用。如果您想深入了解 Heroku 文件系统,可以通过 heroku run bash 获取远程 shell。进一步了解您的应用程序的功能(它是否依赖于数据库?如何配置?)也有助于调试。
  • 我尝试运行 heroic logs --source app,它只说存在安全漏洞,但没有说明任何错误。对于远程外壳,我不知道该怎么做。有没有其他网站可以轻松部署此类项目并且不要求提供信用卡信息?
  • 我认为系统 ruby​​ 已预装在 mac 上?如果不是,我该如何安装它,以解决我的问题的根源。感谢您的帮助。
  • 你能用foreman start web在本地运行你的应用程序吗?
  • 我运行了该命令,它给了我以下错误:错误:无法访问 jarfile 目标/依赖项/jetty-runner.jar。我将 jetty-runner 作为依赖项添加到我的 spring mvc pom.xml 文件中,就像在 heroku 上所说的那样。

标签: java spring spring-mvc heroku


【解决方案1】:

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

需要添加如下插件配置:

  <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 中,以便在运行时使用。

【讨论】:

    猜你喜欢
    • 2018-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多