无法部署到Heroku。 at =错误代码= H10 desc =“App崩溃”

时间:2017-06-01 11:32:44

标签: java spring heroku

我正在尝试将我的应用部署到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";
    }
}

Procfile:

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

Screenshot of my classes and pages here

2 个答案:

答案 0 :(得分:3)

H10错误意味着:网络dyno上的网络dyno崩溃或启动超时将显示此错误。 根据{{​​3}}

  1. 将webapp runner添加到pom.xml中的plugins部分

     <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更改为

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

    然后尝试重新部署。

    查看我在github上部署的这个项目,如果它可以帮助你更多java-webapp-runner

    你能在github上分享项目吗?

答案 1 :(得分:0)

在根文件夹内创建“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

相关问题