gpt4 book ai didi

spring - 将 Spring boot 应用程序部署到 Heroku 时出错

转载 作者:行者123 更新时间:2023-12-02 02:42:21 28 4
gpt4 key购买 nike

我在将 Spring boot 应用程序部署到 Heroku 时遇到问题。

  • 我正在尝试将其部署为 java 应用程序,而不是构建和部署 jar 文件。
  • 我在 Heroku 中使用了免费的 Postgresql。

将应用程序推送到 Heroku master 时出现的错误是:

remote:        [INFO] Changes detected - recompiling the module!
remote: [INFO] Compiling 18 source files to /tmp/build_79201803/target/classes
remote: [INFO] -------------------------------------------------------------
remote: [ERROR] COMPILATION ERROR :
remote: [INFO] -------------------------------------------------------------
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/post.java:[15,8] class Post is public, should be declared in a file named Post.java
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/user.java:[12,8] class User is public, should be declared in a file named User.java
remote: [INFO] 2 errors
remote: [INFO] -------------------------------------------------------------
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] BUILD FAILURE
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 16.300 s
remote: [INFO] Finished at: 2020-08-11T11:09:38Z
remote: [INFO] ------------------------------------------------------------------------
remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project springblog: Compilation failure: Compilation failure:
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/post.java:[15,8] class Post is public, should be declared in a file named Post.java
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/user.java:[12,8] class User is public, should be declared in a file named User.java
remote: [ERROR] -> [Help 1]
remote: [ERROR]
remote: [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
remote: [ERROR] Re-run Maven using the -X switch to enable full debug logging.
remote: [ERROR]
remote: [ERROR] For more information about the errors and possible solutions, please read the following articles:
remote: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
remote:
remote: ! ERROR: Failed to build app with Maven
remote: We're sorry this build is failing! If you can't find the issue in application code,
remote: please submit a ticket so we can help: https://help.heroku.com/
remote:
remote: ! Push rejected, failed to compile Java app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:

此处的错误指定我的 UserPost 模型文件名以小写字母开头。

但是我的文件结构是:

File Structure for the models

我认为错误不在模型中,而且我无法找出问题所在。

最佳答案

我通过将 java 版本 11 更改为 8(在 pom.xml 中)解决了我的问题。

来自:

<properties>
<java.version>11</java.version>
</properties>

致:

<properties>
<java.version>8</java.version>
</properties>

关于spring - 将 Spring boot 应用程序部署到 Heroku 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63357120/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com