当我尝试访问它时,我的部署收到代码错误 H10。
我读到发生这种情况是因为我必须为应用程序设置一个动态端口。
我已经尝试了 Heroku 开发中心上提供的所有配置,但没有运气。
这是我的 pom.xml:
`
<groupId>dogbook</groupId>
<artifactId>dog-book</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>dog-book</name>
<description>Dog Book Backend</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>br.dogbook.Application</start-class>
<full-artifact-name>target/${project.artifactId}-${project.version}.jar</full-artifact-name>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>1.1.GA</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<dotGitDirectory>../.git</dotGitDirectory>
</configuration>
</plugin>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<appName>dog-book</appName>
<includeTarget>false</includeTarget>
<includes>
<include>${basedir}/${full-artifact-name}</include>
</includes>
<jdkVersion>1.8</jdkVersion>
<processTypes>
<web>java $JAVA_OPTS -jar ${full-artifact-name}</web>
</processTypes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.5.11.3</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
`
我的 main/resources/application.yml:
`
server:
port: 8080
---
spring:
profiles: heroku
server:
port: ${PORT}
`
这是完整的错误:(已更新)
`
2017-10-25T04:22:38.012290+00:00 heroku[web.1]: State changed from starting to crashed
2017-10-25T09:51:04.226590+00:00 heroku[web.1]: State changed from crashed to starting
2017-10-25T09:51:06.553784+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=44562 -jar target/dog-book-1.0.jar`
2017-10-25T09:51:07.883843+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-10-25T09:51:07.884774+00:00 app[web.1]: Error: Unable to access jarfile target/dog-book-1.0.jar
2017-10-25T09:51:07.966920+00:00 heroku[web.1]: State changed from starting to crashed
2017-10-25T09:51:07.954716+00:00 heroku[web.1]: Process exited with status 1
2017-10-25T10:50:16.461375+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dog-book.herokuapp.com request_id=945fe406-6784-4a03-8ec3-cd997da8b023 fwd="189.34.55.2" dyno= connect= service= status=503 bytes= protocol=https
2017-10-25T10:50:17.185622+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dog-book.herokuapp.com request_id=01ce7010-cd8d-49f1-a039-f628f0e8e829 fwd="189.34.55.2" dyno= connect= service= status=503 bytes= protocol=https
2017-10-25T11:02:09.761721+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dog-book.herokuapp.com request_id=035c33ce-0340-4695-9c46-0f825bf20a24 fwd="189.34.55.2" dyno= connect= service= status=503 bytes= protocol=https
2017-10-25T11:02:10.575906+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dog-book.herokuapp.com request_id=a52d39bb-f402-4fec-b2f4-9c6888893706 fwd="189.34.55.2" dyno= connect= service= status=503 bytes= protocol=https
`
我已经配置了没有扩展名的 Procfile。
web: $JAVA_OPTS -Dserver.port=$PORT -jar target/dog-book-1.0.jar
而且还是一样。
有任何想法吗 ?
与 Heroku 默认使用的 war 不同,jar 没有监听 Heroku 检查可用性的同一端口。
See https://exampledriven.wordpress.com/2016/11/04/spring-boot-heroku-example/ https://exampledriven.wordpress.com/2016/11/04/spring-boot-heroku-example/
添加的技巧--server.port=$PORT
to Procfile
did not为我工作。
但添加
server.port=${PORT:8080}
到春天的application.properties
被拿起并且工作完美!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)