Java 错误:无法找到或加载主类。使用依赖项运行maven jar

Java 错误:无法找到或加载主类。使用依赖项运行maven jar,java,maven,pom.xml,Java,Maven,Pom.xml,我使用Maven来管理一个个人项目,每当我尝试运行带有依赖项的jar时,都会遇到这个Maven错误 $ java -jar .\SpotifyAutomation-1.0-SNAPSHOT-jar-with-dependencies.jar Error: Could not find or load main class SpotifyRunner (我在运行前进行了清洁和安装) 我的pom文件如下所示: <?xml version="1.0" encoding="UTF-8"?>

我使用Maven来管理一个个人项目,每当我尝试运行带有依赖项的jar时,都会遇到这个Maven错误

$ java -jar .\SpotifyAutomation-1.0-SNAPSHOT-jar-with-dependencies.jar
Error: Could not find or load main class SpotifyRunner
(我在运行前进行了清洁和安装)

我的pom文件如下所示:

<?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>SpotifyAutomation</groupId>
<artifactId>SpotifyAutomation</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib</classpathPrefix>
                        <mainClass>SpotifyRunner</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.4.0</version>
    </dependency>
    <dependency>
        <groupId>se.michaelthelin.spotify</groupId>
        <artifactId>spotify-web-api-java</artifactId>
        <version>1.5.0</version>
    </dependency>
</dependencies>

4.0.0
点化自动化

指定主类不需要完整的包名吗?我没有指定的包,因为项目中只有一个包,所以我认为我不必这样做。考虑到我的项目结构(添加在上面),它会是什么样子?查看jar文件内部,看看类文件的文件名是什么。然后重新构造所需的包名。在查看jar的内容时,我看到大量的类文件。我只是做了一个罐子。有没有更好的办法?谢谢