【问题标题】:Can't deploy to Heroku. at=error code=H10 desc="App crashed"无法部署到 Heroku。 at=错误代码=H10 desc="应用程序崩溃"
【发布时间】:2017-11-02 12:47:34
【问题描述】:

我正在尝试将我的应用部署到 Heroku。我的应用程序崩溃了。这是错误:

at=error code=H10 desc="App crashed" method=GET path="/" 
host=smartmed2017.herokuapp.com request_id=3e8cc17e-320b-4230-bdbb-
3a751e3477de fwd="195.19.247.73" dyno= connect= service= status=503 
bytes= protocol=https

2017-06-01T11:17:42.380548+00:00 heroku[router]: at=error code=H10 
desc="App crashed" method=GET path="/favicon.ico" 
host=smartmed2017.herokuapp.com request_id=9ab6574e-3fed-4af3-9cae-
0651e13d9112 fwd="195.19.247.73" dyno= connect= service= status=503 
bytes= protocol=https

像往常一样,但我这个问题的原因可能不同。

这是 Main.class

@Controller
@SpringBootApplication
public class Main
{
    public static void main(String[] args) throws Exception {
        SpringApplication.run(Main.class, args);
    }

    @RequestMapping("/")
    String index() {
        return "index";
    }
}

过程文件:

web: java -Dserver.port=$PORT -jar target/untitled-1.0-SNAPSHOT.jar

Screenshot of my classes and pages here

【问题讨论】:

  • 你能在重启dyno后运行heroku logs -t并从JVM捕获错误信息吗?
  • @codefinger here。感谢您的回复
  • 你贴的日志不够详细。尝试从头开始复制日志,让我们看看会发生什么。如果您有一个连接到 localhost 的数据库,请检查并更改端口。你有 webapp-runner 添加到 pom.xml 吗?
  • @AwotunboOlakunleOladeji 我还没有使用任何数据库。 First screenshotSecond one。我没有这个。感谢您的帮助!
  • @AwotunboOlakunleOladeji 我的意思是我没有 webapp-runner

标签: java spring heroku


【解决方案1】:

在根文件夹内创建“Procfile”并在其上设置以下代码后,服务器开始工作:

web: java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/my-nice-app-0.0.1-SNAPSHOT.jar

只要确保:

  1. ./gradlew build 有效
  2. ./gradlew bootRun 有效

文档:https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku#prerequisites

【讨论】:

    【解决方案2】:

    H10 错误意味着:网络测功机崩溃或网络测功机上的启动超时将显示此错误。 根据java-webapp-runner

    1. 将 webapp 运行器添加到 pom.xml 中的插件部分

       <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-dependency-plugin</artifactId>
              <version>2.3</version>
              <executions>
                  <execution>
                      <phase>package</phase>
                      <goals><goal>copy</goal></goals>
                      <configuration>
                          <artifactItems>
                              <artifactItem>
                                  <groupId>com.github.jsimone</groupId>
                                  <artifactId>webapp-runner</artifactId>
                                  <version>8.5.11.3</version>
                                  <destFileName>webapp-runner.jar</destFileName>
                              </artifactItem>
                          </artifactItems>
                      </configuration>
                  </execution>
              </executions>
          </plugin>
      
    2. 将您的 Procfile 更改为

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

    然后尝试重新部署。

    看看我在github上部署的这个项目,如果它可以帮助你更多Sample Project on Heroku

    你能在github上分享这个项目吗?

    【讨论】:

    • Here is repo 在那里你会看到 logfile.txt。修改后有错误
    猜你喜欢
    • 2021-01-07
    • 1970-01-01
    • 1970-01-01
    • 2021-02-20
    • 2019-11-02
    • 1970-01-01
    • 2020-09-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多