Ответы пользователя по тегу Maven
  • Почему не найден класс?

    @Ezekiel4 Автор вопроса
    Охотник на пиратов и сборщик монолитов
    Спустя несколько часов поиска разобрался сам. Если у кого будет тот же трабл, оставляю решение. В pom-файл maven-а нужно дописать блок build, добавить плагин maven assembly. Полный текст выглядит так, можете сравнить с этим же текстом выше.

    В строке study.DiscordBot замените содержимое на путь к своему главному классу. Актуальную версию плагина можно взять тут.

    <?xml version="1.0" encoding="UTF-8"?>
    <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>org.example</groupId>
        <artifactId>discord-application</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <properties>
            <maven.compiler.source>16</maven.compiler.source>
            <maven.compiler.target>16</maven.compiler.target>
        </properties>
    
        <dependencies>
            <!-- https://mvnrepository.com/artifact/net.dv8tion/JDA -->
            <dependency>
                <groupId>net.dv8tion</groupId>
                <artifactId>JDA</artifactId>
                <version>5.0.0-alpha.9</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.3.0</version>
                    <configuration>
                        <!-- get all project dependencies -->
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <!-- MainClass in mainfest make a executable jar -->
                        <archive>
                            <manifest>
                                <mainClass>study.DiscordBot</mainClass>
                            </manifest>
                        </archive>
    
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <!-- bind to the packaging phase -->
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
    Ответ написан
    Комментировать