为什么heroku不运行我的部署,但是运行本地就好了?

时间:2019-06-12 14:55:27

标签: java git maven heroku heroku-cli

我正在尝试使用Java和Maven构建将Discord机器人部署到Heroku。我使用maven创建了一个胖的jar,在procfile中引用了它,但我没有发现添加清单属性的必要,而只是将Jar用作类路径。在本地运行该应用程序不会造成任何麻烦,但是在部署时在服务器中运行该应用程序会不断抛出(在heroku日志中):

Error: Could not find or load main class com.alejandro.uwubot.Main

我尝试在本地构建Jar(显然Heroku在服务器端构建了项目本身,而本地提交的文件未提交)。我尝试打开本地制作的Jar,一切似乎都完好无损,因此应该相同,因为应该在服务器端和客户端都运行相同的pom.xml。我运行heroku local worker,它执行得很好。 我只在做部署所需的工作。 git add .git commit -m "message"git push heroku master。似乎每次都成功构建成功。

这是procfile。它只是使用Maven目标目录中的胖子作为类路径,并使用我的主类的全限定名

worker: java -cp target\uwu_bot-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.alejandro.uwubot.Main -Xdiag

这是pom.xml的<build>标记,它使用程序集插件来制作该胖子。

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

我希望客户端和服务器双方都运行相同。但是Heroku正在做些可疑的事情,我不确定是什么。

0 个答案:

没有答案