Java Springboot gradle应用程序赢得';无法在Heroku上运行,无法访问jarfile
我已经将一个存储库推送到Heroku,它似乎构建得很好,但当我尝试访问应用程序时,我在Heroku日志中得到了这个输出-Java Springboot gradle应用程序赢得';无法在Heroku上运行,无法访问jarfile,java,spring-boot,gradle,heroku,Java,Spring Boot,Gradle,Heroku,我已经将一个存储库推送到Heroku,它似乎构建得很好,但当我尝试访问应用程序时,我在Heroku日志中得到了这个输出- 2021-05-02T14:34:47.000000+00:00应用程序[api]:构建成功 2021-05-02T14:34:47.079454+00:00 heroku[web.1]:状态从崩溃变为启动 2021-05-02T14:34:50.727894+00:00 heroku[web.1]:使用命令“java-jar build/libs/web\u quick\u
2021-05-02T14:34:47.000000+00:00应用程序[api]:构建成功
2021-05-02T14:34:47.079454+00:00 heroku[web.1]:状态从崩溃变为启动
2021-05-02T14:34:50.727894+00:00 heroku[web.1]:使用命令“java-jar build/libs/web\u quick\u app-0.0.1-SNAPSHOT.jar”启动进程`
2021-05-02T14:34:53.252888+00:00应用程序[web.1]:根据动态大小设置JAVA工具选项默认值。自定义设置将覆盖它们。
2021-05-02T14:34:53.254210+00:00应用程序[web.1]:错误:无法访问jarfile build/libs/web\u quick\u app-0.0.1-SNAPSHOT.jar
2021-05-02T14:34:53.306310+00:00 heroku[web.1]:进程已退出,状态为1
2021-05-02T14:34:53.355513+00:00 heroku[web.1]:状态从开始更改为崩溃
2021-05-02T14:34:53.364436+00:00 heroku[web.1]:状态从崩溃变为启动
2021-05-02T14:34:57.136511+00:00 heroku[web.1]:使用命令“java-jar build/libs/web\u quick\u app-0.0.1-SNAPSHOT.jar”启动进程`
2021-05-02T14:35:01.345785+00:00应用程序[web.1]:根据动态大小设置JAVA工具选项默认值。自定义设置将覆盖它们。
2021-05-02T14:35:01.347659+00:00应用程序[web.1]:错误:无法访问jarfile build/libs/web\u quick\u app-0.0.1-SNAPSHOT.jar
2021-05-02T14:35:01.444069+00:00 heroku[web.1]:进程已退出,状态为1
2021-05-02T14:35:01.657501+00:00 heroku[web.1]:状态从开始更改为崩溃
2021-05-02T14:35:02.629786+00:00 heroku[路由器]:at=错误代码=H10 desc=“应用程序崩溃”方法=获取路径=“/”主机=spring-web-quick.herokuapp.com请求id=
e9ac6f46-ff2d-4b69-90f3-e2df77aca721 fwd=“31.48.117.16”动态=连接=服务=状态=503字节=协议=https
2021-05-02T14:35:03.132808+00:00 heroku[路由器]:at=错误代码=H10 desc=“应用程序崩溃”方法=获取路径=“/favicon.ico”主机=spring-web-quick.herokuapp.com
请求id=253d1487-6383-4ce2-8724-8133990c8922 fwd=“31.48.117.16”dyno=connect=service=status=503字节=protocol=https
我可以在本地运行build gradle
,并在build/libs/web\u quick\u app-0.0.1-SNAPSHOT.jar
中创建一个jar文件
我可以在本地运行jarjava-jarbuild/libs/web\u quick\u app-0.0.1-SNAPSHOT.jar
和Springboot加载
我在回购协议中添加了一个proc文件-
web: java -jar build/libs/web_quiz_app-0.0.1-SNAPSHOT.jar
将端口添加到Procfile-
web: java -Dserver.port=$PORT -jar build/libs/web_quiz_app-0.0.1-SNAPSHOT.jar
这是我的build.gradle
文件-
plugins {
id 'org.springframework.boot' version '2.3.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'io.github.siaust'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
// New dependencies for a H2 database
// implementation 'org.springframework.boot:sweb'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'com.h2database:h2'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
// For Hyperskill tests
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.2.5.RELEASE'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security' // , version: '2.3.1.RELEASE'
// For colour output to console
implementation group: 'com.diogonunes', name: 'JCDP', version: '4.0.2'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf', version: '2.3.1.RELEASE'
// This enables hotswapping (refresh browser without restarting app)
// https://stackoverflow.com/questions/23155244/spring-boot-hotswap-with-intellij-ide
compile("org.springframework.boot:spring-boot-devtools")
}
test {
useJUnitPlatform()
}
jar {
archiveBaseName = 'app'
archiveVersion = '0.0.1'
}
我从Heroku那里找不到任何关于这方面的信息,在google上也只找到了一些
编辑-
尝试在build.gradle
中使用bootJar
任务,相同错误无法访问jarfile
-
bootJar {
archiveBaseName = 'web-quiz-app'
archiveVersion = '0.1'
}
编辑:我可以使用heroku local
除了使用Springboot CLI创建Gradle项目而不是Maven项目外,我还按照指南完成了一个测试应用程序。最初我有一个错误,通过下面的system.properties
文件解决了。现在,它成功地在Heroku上构建和运行。我所能看到的唯一区别是一个system.properties
文件,我后来将它添加到了我的原始项目中-
java.runtime.version=11
这对原始回购协议没有影响