heroku-spring应用程序生成成功,但运行失败

g6baxovj  于 2021-07-23  发布在  Java
关注(0)|答案(1)|浏览(330)

我已经用spring构建了一个web应用程序,它在localhost中工作。当我使用以下日志将其部署到heroku时,构建成功

-----> Building on the Heroku-18 stack
-----> Java app detected
-----> Installing JDK 11... done
-----> Executing Maven
       $ ./mvnw -DskipTests clean dependency:list install
       [INFO] Scanning for projects...
       [INFO] 
       [INFO] -------------------------< sg.edu.iss:mytrial >-------------------------
       [INFO] Building mytrial 0.0.1-SNAPSHOT
       [INFO] --------------------------------[ jar ]---------------------------------
       [INFO] 
       [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ mytrial ---
       [INFO] 
       [INFO] --- maven-dependency-plugin:3.1.2:list (default-cli) @ mytrial ---
       [INFO] 
       [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ mytrial ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Using 'UTF-8' encoding to copy filtered properties files.
       [INFO] Copying 1 resource
       [INFO] Copying 27 resources
       [INFO] The encoding used to copy filtered properties files have not been set. This means that the same encoding will be used to copy filtered properties files as when copying other filtered resources. This might not be what you want! Run your build with --debug to see which files might be affected. Read more at https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ mytrial ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 57 source files to /tmp/build_901df98b/target/classes
       [INFO] /tmp/build_901df98b/src/main/java/sg/edu/iss/ca/controller/MyErrorController.java: /tmp/build_901df98b/src/main/java/sg/edu/iss/ca/controller/MyErrorController.java uses or overrides a deprecated API.
       [INFO] /tmp/build_901df98b/src/main/java/sg/edu/iss/ca/controller/MyErrorController.java: Recompile with -Xlint:deprecation for details.
       [INFO] 
       [INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ mytrial ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Using 'UTF-8' encoding to copy filtered properties files.
       [INFO] skip non existing resourceDirectory /tmp/build_901df98b/src/test/resources
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ mytrial ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 8 source files to /tmp/build_901df98b/target/test-classes
       [INFO] 
       [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ mytrial ---
       [INFO] Tests are skipped.
       [INFO] 
       [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ mytrial ---
       [INFO] Building jar: /tmp/build_901df98b/target/mytrial-0.0.1-SNAPSHOT.jar
       [INFO] 
       [INFO] --- spring-boot-maven-plugin:2.4.1:repackage (repackage) @ mytrial ---
       [INFO] Replacing main artifact with repackaged archive
       [INFO] 
       [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ mytrial ---
       [INFO] Installing /tmp/build_901df98b/target/mytrial-0.0.1-SNAPSHOT.jar to /tmp/codon/tmp/cache/.m2/repository/sg/edu/iss/mytrial/0.0.1-SNAPSHOT/mytrial-0.0.1-SNAPSHOT.jar
       [INFO] Installing /tmp/build_901df98b/pom.xml to /tmp/codon/tmp/cache/.m2/repository/sg/edu/iss/mytrial/0.0.1-SNAPSHOT/mytrial-0.0.1-SNAPSHOT.pom
       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD SUCCESS
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time:  11.243 s
       [INFO] Finished at: 2021-03-10T02:49:37Z
       [INFO] ------------------------------------------------------------------------
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 102.6M
-----> Launching...
       Released v30
       https://cims-spring.herokuapp.com/ deployed to Heroku

但是,当我尝试运行应用程序时,heroku日志中显示以下错误:

2021-03-10T02:51:20.125315+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cims-spring.herokuapp.com request_id=e3bf1cbe-0a85-46a6-91c5-e9be443b8724 fwd="220.255.55.225" dyno= connect= service= status=503 bytes= protocol=https
2021-03-10T02:51:20.565627+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cims-spring.herokuapp.com request_id=540479be-1d1b-4504-b2b2-90605841225f fwd="220.255.55.225" dyno= connect= service= status=503 bytes= protocol=https

代码的存储库可以在这里找到
请帮帮我,我已经尝试了所有我能在谷歌找到的,我的想法

ttygqcqt

ttygqcqt1#

heroku默认使用openjdk8来运行应用程序,要更改版本,必须在应用程序中添加一个名为system.properties的文件。
在文件中设置属性java.runtime.version:

java.runtime.version=11

要了解更多信息,请查看此处https://devcenter.heroku.com/articles/java-support
如果可能的话,您可以将您的java版本11更改为8,这将更容易在默认情况下使用java 8在heroku上部署您的应用程序。

相关问题