为什么我的java程序抛出java.lang. nosuchmethoderror使用JDA在heroku?



我在Heroku上托管了这个java discord bot,在升级到最新版本的JDA后,我不得不将onGuildMessageReceived更改为onMessageReceived。当从intelllij运行我的bot时,它没有任何问题,但当从Heroku执行它时,它会给我"java.lang。NoSuchMethodError:"net.dv8tion.jda.api.entities。音频信道net.dv8tion.jda.api.entities.GuildVoiceState.getChannel()";每次我在Discord上发消息。导致此错误的代码为:AudioChannel audioChannel = e.getMember().getVoiceState().getChannel();inside ofonMessageReceived.

我个人觉得maven可能导入了错误的版本到Heroku,但我没有任何方法来检查它,所以这里是我的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">
<build>
<plugins>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.furetto126.furettobot.FurettoBot</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modelVersion>4.0.0</modelVersion>
<groupId>com.furetto126.furettobot</groupId>
<artifactId>FurettoBot</artifactId>
<version>1.1</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<repositories>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sedmelluq</groupId>
<artifactId>lavaplayer</artifactId>
<version>1.3.77</version>
</dependency>
</dependencies>
</project>

根据我的经验,java.lang.NoSuchMethodError通常意味着存在jar冲突,这表明有多个jar文件包含某个class。你可以简单地双击shift并搜索特定的类名来检查是否有多个jar包含特定的类