gpt4 book ai didi

java - 当运行可执行 jar 文件时,我有 SQLException : No suitable driver found for jdbc:mysql://localhost:3306/DENTAL

转载 作者:行者123 更新时间:2023-12-01 17:30:11 25 4
gpt4 key购买 nike

我正在开发一个项目,我的项目应该与数据库连接,当我在NetBeans上运行它时它工作得很好,但是当我尝试运行可执行 jar 文件我有这样的错误,

“找不到适用于 jdbc:mysql://localhost:3306/DENTAL 的驱动程序”

请注意,我已将 mysql-connecter.jar 添加到库中。

谢谢

最佳答案

请使用以下命令生成jar文件:

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>edu.learn.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-runnable-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

然后运行 ​​mvn clean package

关于java - 当运行可执行 jar 文件时,我有 SQLException : No suitable driver found for jdbc:mysql://localhost:3306/DENTAL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61137277/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com