没有找到适合jdbc的驱动程序:postgresql-可执行java jar

没有找到适合jdbc的驱动程序:postgresql-可执行java jar,java,maven,Java,Maven,当我在eclipse中以java应用程序的形式运行该项目时,它工作得非常好,但在windows cmd上运行java-jar会引发SQL异常(找不到合适的驱动程序) 我使用maven(maven assembly)创建了可执行jar,在project\target中创建了一个具有依赖项的jar。 postgresqljar(postgresql-42.2.5.jar)存在于project\lib文件夹中 <plugin> <artifactId>

当我在eclipse中以java应用程序的形式运行该项目时,它工作得非常好,但在windows cmd上运行
java-jar
会引发SQL异常(找不到合适的驱动程序)

我使用maven(maven assembly)创建了可执行jar,在project\target中创建了一个具有依赖项的jar。 postgresqljar(postgresql-42.2.5.jar)存在于project\lib文件夹中

 <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.project.Main</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                  <phase>package</phase>
                  <goals>
                    <goal>single</goal>
                  </goals>
                </execution>
            </executions>
        </plugin>
我希望清单文件中的类路径能够解决这个问题,但事实并非如此


可能是重复的帖子,但现有的解决方案都没有解决我的问题。

你在pom.xml中添加依赖项了吗?@Vishal是的,我添加了,用pom dependency更新了问题描述可能对你有帮助:@BonumUrsus谢谢,我使用了maven汇编插件,它应该添加dependencies@BonumUrsus把它改成maven shade确实对我有用,谢谢!
 <dependencies>
   <dependency>
     <groupId>postgresql</groupId>
     <artifactId>postgresql</artifactId>
     <version>${postgres.driver.version}</version>
   </dependency>
 </dependencies>