java - 访问 Heroku 端点 - SpringBootApp 503Service 不可用
问题描述
我现在在 Heroku 中部署了一个 springBoot 应用程序,我想向这个应用程序发出一些请求,但我收到了 503 错误消息。
在我的本地,我使用下一个 url 来执行获取请求:http://localhost:8080/suggestions?q=Londo&latitude=43.70011&longitude=-79.4163
在 Heroku 中,我使用了下一个网址: https://heroku-boot-app-chall.herokuapp.com/suggestions?q=Londo&latitude=43.70011&longitude=-79.4163。我不太确定如何向部署在 Heroku 中的应用程序发出请求,构建成功。我只是在 github 和 Heroku 中提交我的资源我必须再做一步才能做一些请求?
这些是日志:
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
谢谢!
解决方案
最后,我必须使用以下信息创建一个 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>
推荐阅读
- python - 列表中的字符-数字对:当我知道字符/字母时如何获取数字?
- reactjs - 我的代码中有什么错误导致这句话弹出“期望一个赋值或函数调用,而不是看到一个表达式”?
- parallel-processing - 使用 lbzip2 指定 tar 中使用的核心数
- language-agnostic - 有向循环图的人类可读文本表示
- django - 为什么 Django URL 转换器类型不起作用?
- ios - 无法为 AVPlayer 更新 iOS 远程命令中心?
- android - React-Native 0.60.5 启动时崩溃 (Android)
- kubernetes - GKE集群节点上的“可分配cpu”和“分配的cpu限制”有什么区别
- python - asyncpg SELECT WHERE IN 给出 postgresSyntaxError
- user-interface - 如何使 ScrollRect 平滑移动?