英文:
Acces to Heroku Endpoint - SpringBootApp 503Service Unavailable
问题
以下是翻译好的内容:
我现在在Heroku上部署了一个SpringBoot应用,我想向这个应用发送一些请求,但是我收到了一个503错误消息。
在我的本地环境中,我使用以下URL进行GET请求:http://localhost:8080/suggestions?q=Londo&latitude=43.70011&longitude=-79.4163
而在Heroku上,我使用以下URL:
https://heroku-boot-app-chall.herokuapp.com/suggestions?q=Londo&latitude=43.70011&longitude=-79.4163。我不太确定如何向我部署在Heroku上的应用发送请求,构建已成功。我只是将我的源代码提交到GitHub,我需要在能够发送请求之前执行其他步骤吗?
以下是日志:
2020-03-15T22:41:18.739435+00:00 heroku[web.1]: 状态从崩溃变为启动中
2020-03-15T22:41:24.686661+00:00 heroku[web.1]: 正在使用命令启动进程:java -Dserver.port=25003 $JAVA_OPTS -jar target/backend-coding-challenge-1.0-SNAPSHOT.jar
2020-03-15T22:41:26.617949+00:00 heroku[web.1]: 状态从启动中变为崩溃
2020-03-15T22:41:26.596700+00:00 heroku[web.1]: 进程以状态1退出
2020-03-15T22:41:26.457261+00:00 app[web.1]: 创建Procfile以自定义用于运行此进程的命令:https://devcenter.heroku.com/articles/procfile
2020-03-15T22:41:26.469191+00:00 app[web.1]: 根据动态大小设置JAVA_TOOL_OPTIONS的默认值。自定义设置将覆盖它们。
2020-03-15T22:41:26.472555+00:00 app[web.1]: 使用JAVA_TOOL_OPTIONS:-Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-03-15T22:41:26.557238+00:00 app[web.1]: 在target/backend-coding-challenge-1.0-SNAPSHOT.jar中没有找到主清单属性
2020-03-15T22:46:51.520471+00:00 heroku[router]: 错误码=H10 描述="应用崩溃" 方法=GET 路径="/robots.txt" 主机=heroku-boot-app-chall.herokuapp.com 请求ID=5d91aac3-05d9-4075-83ce-1eea931f5a32 客户端IP="94.130.167.85" dyno= 连接= 服务= 状态=503 字节= 协议=https
2020-03-15T22:46:52.053784+00:00 heroku[router]: 错误码=H10 描述="应用崩溃" 方法=GET 路径="/suggestions?q=Londo&latitude=43.70011&longitude=-79.4163" 主机=heroku-boot-app-chall.herokuapp.com 请求ID=b9ba4950-1f83-4959-bc79-901a96d5fd02 客户端IP="94.130.167.85" dyno= 连接= 服务= 状态=503 字节= 协议=https
谢谢!
英文:
I have a springBoot App deployed in Heroku now, I would like to do some request to this App but I am getting a 503 error message.
In my local I use the next url to do the get request: http://localhost:8080/suggestions?q=Londo&latitude=43.70011&longitude=-79.4163
And in Heroku I'm using the next url:
https://heroku-boot-app-chall.herokuapp.com/suggestions?q=Londo&latitude=43.70011&longitude=-79.4163. I am not pretty sure how can I make request to my App deployed in Heroku the build was success. I just commit my sources in github and Heroku I have to do another step before to be able to do some request?
These are the logs:
2020-03-15T22:41:18.739435+00:00 heroku[web.1]: State changed from crashed to starting
2020-03-15T22:41:24.686661+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=25003 $JAVA_OPTS -jar target/backend-coding-challenge-1.0-SNAPSHOT.jar`
2020-03-15T22:41:26.617949+00:00 heroku[web.1]: State changed from starting to crashed
2020-03-15T22:41:26.596700+00:00 heroku[web.1]: Process exited with status 1
2020-03-15T22:41:26.457261+00:00 app[web.1]: Create a Procfile to customize the command used to run this process: https://devcenter.heroku.com/articles/procfile
2020-03-15T22:41:26.469191+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2020-03-15T22:41:26.472555+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-03-15T22:41:26.557238+00:00 app[web.1]: no main manifest attribute, in target/backend-coding-challenge-1.0-SNAPSHOT.jar
2020-03-15T22:46:51.520471+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=heroku-boot-app-chall.herokuapp.com request_id=5d91aac3-05d9-4075-83ce-1eea931f5a32 fwd="94.130.167.85" dyno= connect= service= status=503 bytes= protocol=https
2020-03-15T22:46:52.053784+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/suggestions?q=Londo&latitude=43.70011&longitude=-79.4163" host=heroku-boot-app-chall.herokuapp.com request_id=b9ba4950-1f83-4959-bc79-901a96d5fd02 fwd="94.130.167.85" dyno= connect= service= status=503 bytes= protocol=https
Thanks!
答案1
得分: 0
最后,我不得不创建一个包含以下信息的 Procfile:
web: java -Dserver.port=$PORT -jar target/backend-coding-challenge-1.0-SNAPSHOT.jar
并且在 pom.xml 中添加以下插件:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.heroku.CityAutocompleteService</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
英文:
Finally, I had to create a Procfile with the next info:
web: java -Dserver.port=$PORT -jar target/backend-coding-challenge-1.0-SNAPSHOT.jar
And add the next plugin to the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.heroku.CityAutocompleteService</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
专注分享java语言的经验与见解,让所有开发者获益!
评论