如何解决在 heroku 上部署 Java Maven 电报机器人
我正在尝试通过 github 在 Heroku 上部署在 java maven 中编程的电报机器人,当我在本地运行它时工作。 当我通过 git 在 heroku 上编译它时,它告诉我:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.117 s
[INFO] Finished at: 2020-12-23T11:09:02Z
[INFO] ------------------------------------------------------------------------
-----> Discovering process types
Procfile declares types -> worker
-----> Compressing...
Done: 82M
-----> Launching...
Released v5
https://region-color-telegram-bot.herokuapp.com/ deployed to Heroku
但机器人不起作用。
当我点击heroku上的“打开应用程序”时,它说应用程序错误,并在日志中比较:
2020-12-23T11:12:58.208916+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=region-color-telegram-bot.herokuapp.com request_id=b85e1cf3-d868-45ce-b30e-3c4e31ea627a fwd="151.70.209.200" dyno= connect= service= status=503 bytes= protocol=https
2020-12-23T11:12:58.460646+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=region-color-telegram-bot.herokuapp.com request_id=20278d73-ee00-439d-9475-11b9213250b4 fwd="151.70.209.200" dyno= connect= service= status=503 bytes= protocol=https
在我的 Procfile 中我写了这个:
worker: java -jar target/RegionColor-0.0.1-SNAPSHOT.jar TelegramBot.RegionColor.Main
(我也尝试过用 web 改变 worker)
这就是 pom.xml 的内容:
<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>TelegramBot</groupId>
<artifactId>RegionColor</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>RegionColor</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>4.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>TelegramBot.RegionColor.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>TelegramBot.RegionColor.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
正如您从 pom 中的库中看到的,bot 对 MySQL 数据库进行了一些调用,但这已经在线托管并且可以正常工作。
不幸的是,我对 pom 或 procfile 的使用缺乏经验,如果我写了一些巨大的废话,我提前道歉。 谁能告诉我要更改什么才能使机器人工作? 谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。