Heroku上的Java Spring MVC错误:无法访问jarfile target/dependency/webapp-runner.jar

Heroku上的Java Spring MVC错误:无法访问jarfile target/dependency/webapp-runner.jar,java,postgresql,heroku,jar,webapp-runner,Java,Postgresql,Heroku,Jar,Webapp Runner,我使用Heroku部署带有PostgreSQL数据库的Spring MVC java应用程序。数据库链接工作正常,PostgreSQL初始化成功 部署成功,没有错误或奇怪的警告消息,但现在应用程序失败 以下是日志: heroku[web.1]: State changed from crashed to starting heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dspring.profiles.

我使用Heroku部署带有PostgreSQL数据库的Spring MVC java应用程序。数据库链接工作正常,PostgreSQL初始化成功

部署成功,没有错误或奇怪的警告消息,但现在应用程序失败

以下是日志:

    heroku[web.1]: State changed from crashed to starting
    heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dspring.profiles.active="datajpa,heroku" -DMISIC_ROOT="." -jar target/dependency/webapp-runner.jar --port 28363 target/*.war`
    heroku[web.1]: State changed from starting to crashed
    heroku[web.1]: Process exited with status 1
    app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
    app[web.1]: Error: Unable to access jarfile target/dependency/webapp-runner.jar
    heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=misic.herokuapp.com request_id=a242ee89-5594-4f48-9d14-432d46b17600 fwd="178.21.66.110" dyno= connect= service= status=503 bytes= protocol=https
我没有找到关于stackoverflow的任何答案,这将解决我的问题。 为什么Heroku找不到webapp-runner.jar,我不知道! 在localhost上,一切工作都很完美

My pom.xml(部分)

链接到Github:



我解决了这个问题。出于某种原因,Heroku不使用文件setings.xml。当我将此文件的内容传输到pom.xml并将其删除时,一切正常。

请确保您的
pom.xml中有类似的内容:

        <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>9.0.13.0</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

org.apache.maven.plugins
当我试图通过git而不是jarfile来部署jhipster upp时,我遇到了这个问题。我之所以拥有它,是因为Node.js buildpack是在java的buildpack之前启动的,所以我被迫用
heroku:buildpacks add--index 2 heroku/nodejs
和heroku:buildpacks add--index 1 heroku/java`来设置它们,但即使在这一更改之后,我仍然有相同的错误。2) 然后我意识到我在pom、xml中使用了jar打包,而不是必需的war打包。将此值更改为pom.xml对我有帮助

请查看我的答案,以便找到您的Procfile。这是我的配置

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>6.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </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>9.0.24.0</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        </plugins>
    </build>

org.apache.maven.plugins
maven编译器插件
2.3.2
1.6
1.6
${annowed.dir}
org.apache.maven.plugins
maven战争插件
2.1.1
假的
org.apache.maven.plugins
maven依赖插件
2.1
验证
复制
${annowed.dir}
真的
爪哇
javaee认可的api
6
罐子
org.apache.maven.plugins
maven依赖插件
包裹
复制
com.github.jsimone
webapprunner
9.0.24.0
webapp-runner.jar

在尝试在heroku上部署Procfile之前,我意识到Procfile应该存在并在repo上正确创建
        <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>9.0.13.0</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>6.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </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>9.0.24.0</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        </plugins>
    </build>