在heroku上部署javamaven电报机器人

vxqlmq5t  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(225)

我正试图通过github在heroku上部署一个用javamaven编程的telegrambot,在本地运行时工作。当我通过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上的“打开应用程序”时,它会显示应用程序错误,并在日志compair中显示:

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

在我的文件里我写了这样一句话:

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的使用缺乏经验,如果我写了一些无稽之谈,我会提前道歉。有人能告诉我要改变什么才能让机器人工作吗?谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题