0

我正在尝试通过 Heroku 在 Spring Tool Suite (windows) 上部署我的项目。我按照 Heroku 的说明进行操作:https ://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku 但它仍然不起作用:https ://invoicepaymentapp.herokuapp.com/

这是日志信息:

2018-01-02T01:15:58.569490+00:00 heroku[web.1]: Starting process with command 
`java -Dserver.port=40785 -jar target/paymmentApp-0.0.1-SNAPSHOT.jar`
2018-01-02T01:16:01.342101+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS 
defaults based on dyno size. Custom settings will override them.
2018-01-02T01:16:01.343156+00:00 app[web.1]: Error: Unable to access jarfile 
target/paymmentApp-0.0.1-SNAPSHOT.jar
2018-01-02T01:16:01.481789+00:00 heroku[web.1]: State changed from starting 
to crashed
2018-01-02T01:16:01.466643+00:00 heroku[web.1]: Process exited with status 1
2018-01-02T01:22:34.997753+00:00 heroku[router]: at=error code=H10 desc="App 
crashed" method=GET path="/" host=invoicepaymentapp.herokuapp.com 
request_id=a7723424-478b-42c0-aa50-96d0fea721c9 fwd="24.27.72.43" dyno= 
connect= service= status=503 bytes= protocol=https
2018-01-02T01:22:35.206610+00:00 heroku[router]: at=error code=H10 desc="App 
crashed" method=GET path="/favicon.ico" host=invoicepaymentapp.herokuapp.com 
request_id=61fa5e70-e1a1-444c-9d1f-9a6660c7a010 fwd="24.27.72.43" dyno= 
connect= service= status=503 bytes= protocol=https
2018-01-02T01:52:05.143835+00:00 heroku[router]: at=error code=H10 desc="App 
crashed" method=GET path="/" host=invoicepaymentapp.herokuapp.com 
request_id=2d5cf43c-bf17-48e9-a66c-eb5822534ec1 fwd="24.27.72.43" dyno= 
connect= service= status=503 bytes= protocol=https
2018-01-02T01:52:11.093114+00:00 heroku[router]: at=error code=H10 desc="App 
crashed" method=GET path="/favicon.ico" host=invoicepaymentapp.herokuapp.com 
request_id=1ec5eeb6-abb6-4036-9b7d-6d66089e7d3f fwd="24.27.72.43" dyno= 
connect= service= status=503 bytes= protocol=https
2018-01-02T01:53:13.985380+00:00 heroku[router]: at=error code=H10 desc="App 
crashed" method=GET path="/favicon.ico" host=invoicepaymentapp.herokuapp.com 
request_id=e3cd1194-7644-4994-b553-bdc117a4448d fwd="24.27.72.43" dyno= 
connect= service= status=503 bytes= protocol=https
2018-01-02T01:53:13.695494+00:00 heroku[router]: at=error code=H10 desc="App 
crashed" method=GET path="/" host=invoicepaymentapp.herokuapp.com 
request_id=47be7a2f-71cb-4b22-8cd3-033b0ac56d43 fwd="24.27.72.43" dyno= 
connect= service= status=503 bytes= protocol=https

我将我的项目推送到 github:https ://github.com/rodCurvelo/paymentapp

我通过以下方式创建了一个heroku应用程序:

$heroku create invoicepaymentapp 

我尝试按照 Procfile.windows 的说明进行操作:Exception deploying Spring Boot app local with Heroku

但我认为我的项目中的 pom.xml、Procfile 或 application.properties 文件有问题:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                <modelVersion>4.0.0</modelVersion>

                <groupId>com.jacana</groupId>
                <artifactId>paymmentApp</artifactId>
                <version>0.0.1-SNAPSHOT</version>

                <name>paymmentApp </name>
                <description>Demo project for Spring Boot</description>

                <parent>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-parent</artifactId>
                    <version>1.5.9.RELEASE</version>
                    <relativePath/> <!-- lookup parent from repository -->
                </parent>

                <properties>
                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
                    <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-thymeleaf</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-tomcat</artifactId>
                        <scope>provided</scope>
                    </dependency>

            <!--         <dependency> 
                        <groupId>mysql</groupId> 
                        <artifactId>mysql-connector-java</artifactId> 
                    </dependency>  --> 


                    <dependency>
                        <groupId>org.postgresql</groupId>
                        <artifactId>postgresql</artifactId>
                        <version>9.4-1201-jdbc4</version>
                    </dependency>  


                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-test</artifactId>
                        <scope>test</scope>
                    </dependency>

                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-devtools</artifactId>
                    </dependency>

                </dependencies>

                <build>
                    <finalName>${project.artifactId}</finalName>
                    <plugins>
                        <plugin>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-maven-plugin</artifactId>
                        </plugin>
                    </plugins>
                </build>


            </project>

档案:

web: java -Dserver.port=$PORT -jar target/paymmentApp-0.0.1-SNAPSHOT.jar

应用程序属性:

spring.datasource.driverClassName=org.postgresql.Driver
            spring.datasource.data-username=vtmzuyhrfszatl  
            spring.datasource.data-password=42ac2524d43c723f7a36217e679297dee16076f5a38ddadb32e13f0bb45d02b0
            spring.datasource.url=jdbc:postgres://vtmzuyhrfszatl:42ac2524d43c723f7a36217e679297dee16076f5a38ddadb32e13f0bb45d02b0@ec2-54-235-148-19.compute-1.amazonaws.com:5432/d3khv24od2njr7
            spring.jpa.hibernate.ddl-auto=update
            spring.jooq.sql-dialect=Postgres

(用户、密码等基于我的heroku数据库账号)

我按照 Procfile.windows 的说明进行操作,但它对我不起作用: Exception deploying Spring Boot app local with Heroku

4

1 回答 1

0

您包含<finalName>${project.artifactId}</finalName>pom.xml中- 这告诉 maven 生成 jar 文件名,如您project.artifactId-paymmentApp.jar。所以:

1)<finalName>${project.artifactId}</finalName>从 pom.xml 中删除,

2) 或编辑您的 Procfile: web: java -Dserver.port=$PORT -jar target/paymmentApp.jar,

3)或像这样:web: java -Dserver.port=$PORT -jar target/*.jar

于 2018-01-02T14:44:03.253 回答