spring引导构建正常,但heroku部署失败

zd287kbt  于 2021-07-07  发布在  Java
关注(0)|答案(1)|浏览(304)

我查了很多遍,没有找到有用的答案。我正在尝试用heroku部署这个api。这是一个预先存在的github存储库,我遵循了heroku的devcenter指南。我尝试通过git和heroku maven插件进行部署,结果是一样的:我可以在本地构建它,一切都很好,但是当我使用cd ~/workspace/API/myapi/ 把它推给希罗库 git push heroku main:main 我得到:

Enumerating objects: 237, done.
Counting objects: 100% (237/237), done.
Delta compression using up to 4 threads
Compressing objects: 100% (179/179), done.
Writing objects: 100% (237/237), 91.06 KiB | 4.14 MiB/s, done.
Total 237 (delta 61), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Java app detected
remote: -----> Installing JDK 11... done
remote: -----> Executing Maven
remote:        $ ./mvnw -DskipTests clean dependency:list install
remote: ./mvnw: 219: ./mvnw: cannot open /tmp/build_f4dfb6d1/API/myapi/.mvn/wrapper/maven-wrapper.properties: No such file
remote: /tmp/build_f4dfb6d1/API/myapi/.mvn/wrapper/maven-wrapper.jar: No such file or directory
remote: Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain
remote: Caused by: java.lang.ClassNotFoundException: org.apache.maven.wrapper.MavenWrapperMain
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: 
remote: !       Push rejected to myapiheroku.
remote: 
To https://git.heroku.com/cashonlineheroku.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myapiheroku.git'
``` `/home/myuser/workspace/API/myapi/.mvn/wrapper/` 包含文件 `maven-wrapper.jar` ,  `maven-wrapper.properties` 以及 `MavenWrapperDownloader.java` . `/home/myuser/workspace/API/myapi/system.properties` 指定 `java.runtime.version=11` . `/home/myuser/.m2/repository/ar/com/api/myapi/` 包含 `myapi.0.0.1-SNAPSHOT.jar` .
你可以找到 `pom.xml` ,  `application.properties` ,等等。
我错过了什么?如果你需要更多的信息,请告诉我。提前谢谢!
gt0wga4j

gt0wga4j1#

看起来你有一个 mvnw 文件位于项目目录的根目录中,但缺少maven Package 器所需的其他文件。它们通常居住在 .mvn/wrapper 应用程序的目录。你可能已经删除了它们。
您有两种选择:
同时删除maven wrapper的其他文件: mvnw 以及 mvnw.cmd 重新安装maven wrapper缺少的文件: mvn -N io.takari:maven:0.7.7:wrapper 我会选择第二种。通常首选使用 Package 器来确保您的项目以您期望的maven版本运行。

相关问题