【发布时间】:2021-05-02 19:33:15
【问题描述】:
我有一个在 IntelliJ IDE 中运行良好的 spring-boot 项目,我尝试将它部署在 Heroku 服务器上。该项目已成功部署,但当我尝试从 POSTMAN 访问它时,我收到 503 错误:服务不可用。
从 Heroku 成功部署后的日志记录如下:
-----> Building on the Heroku-20 stack
-----> Java app detected
-----> Installing JDK 1.8... done
-----> Executing Maven
$ ./mvnw -DskipTests clean dependency:list install
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< io.slcoder:authentication-server >-----------------
[INFO] Building authentication-server 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ authentication-server ---
[INFO]
[INFO] --- maven-dependency-plugin:3.1.2:list (default-cli) @ authentication-server ---
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ authentication-server ---
[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 1 resource
[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) @ authentication-server ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to /tmp/build_d09a68b1_/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ authentication-server ---
[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_d09a68b1_/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ authentication-server ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /tmp/build_d09a68b1_/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ authentication-server ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:3.3.1:war (default-war) @ authentication-server ---
[INFO] Packaging webapp
[INFO] Assembling webapp [authentication-server] in [/tmp/build_d09a68b1_/target/authentication-server-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Building war: /tmp/build_d09a68b1_/target/authentication-server-0.0.1-SNAPSHOT.war
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.1:repackage (repackage) @ authentication-server ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ authentication-server ---
[INFO] Installing /tmp/build_d09a68b1_/target/authentication-server-0.0.1-SNAPSHOT.war to /tmp/codon/tmp/cache/.m2/repository/io/slcoder/authentication-server/0.0.1-SNAPSHOT/authentication-server-0.0.1-SNAPSHOT.war
[INFO] Installing /tmp/build_d09a68b1_/pom.xml to /tmp/codon/tmp/cache/.m2/repository/io/slcoder/authentication-server/0.0.1-SNAPSHOT/authentication-server-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.024 s
[INFO] Finished at: 2021-01-28T20:29:08Z
[INFO] ------------------------------------------------------------------------
-----> Discovering process types
Procfile declares types -> (none)
-----> Compressing...
Done: 149.5M
Heroku 的应用程序日志:
2021-01-28T21:06:14.000000+00:00 app[api]: Build started by user slcoder@gmail.com
2021-01-28T21:06:43.212587+00:00 app[api]: Release v12 created by user slcoder@gmail.com
2021-01-28T21:06:43.212587+00:00 app[api]: Deploy f113390b by user slcoder@gmail.com
2021-01-28T21:06:50.000000+00:00 app[api]: Build succeeded
2021-01-28T21:06:55.588865+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=authentication-server-app.herokuapp.com request_id=8710722d-c858-423a-bb8b-9268ef8318f3 fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-28T21:06:59.516531+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=authentication-server-app.herokuapp.com request_id=0d6f4102-5dba-44b4-b717-d6d732d236bd fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T00:17:50.789994+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=authentication-server-app.herokuapp.com request_id=fcba05fd-3c76-4830-af3e-dfc697b2f190 fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T00:17:52.530644+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=authentication-server-app.herokuapp.com request_id=77736faf-0206-49dc-80be-3a1c0b5f061a fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T11:20:59.963444+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=authentication-server-app.herokuapp.com request_id=c66098e0-1893-4d3f-90e3-e08f3afe0cea fwd="160.177.175.70" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T11:21:02.909523+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=authentication-server-app.herokuapp.com request_id=ee94b09c-f8c8-4783-a951-0c511007f93f fwd="160.177.175.70" dyno= connect= service= status=503 bytes= protocol=https
这是我的 POM.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.slcoder</groupId>
<artifactId>authentication-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>authentication-server</name>
<description>Server dedicated to authentication</description>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.properties:
spring.datasource.url=jdbc:mysql://zt9j9hwaktmzqprk:eayk987igm1t1shd@esilxl0nthgloe1y.chr7pe7iynqr.eu-west-1.rds.amazonaws.com:3306/vqa34ov9ga2iumfm
spring.datasource.username=zt9j9hwaktmzqprk
spring.datasource.password=****************
spring.datasource.initialization-mode = always
spring.datasource.max-active=10
谁能帮帮我?提前致谢。
【问题讨论】:
-
你能发布你正在运行的应用程序的输出吗?
heroku logs -
我刚刚加了,是第二个sn-p
标签: java spring-boot maven heroku deployment