英文:
When run executable jar file i have and SQLException: No suitable driver found for jdbc:mysql://localhost:3306/DENTAL
问题
我正在进行一个项目,我的项目应该与“数据库”连接,当我在“NetBeans”上运行它时,它完美运行。但是当我尝试运行可执行的jar文件时,我遇到了以下错误,
"找不到适用于jdbc:mysql://localhost:3306/DENTAL的合适的驱动程序"
请注意,我已经将“mysql-connector.jar”添加到库中。
谢谢
英文:
I am working on a project, my project should be connected with Database, When I run it on NetBeans it works perfectly, But when I am try to run the executable jar file i have an error like this,
"No suitable driver found for jdbc:mysql://localhost:3306/DENTAL"
please note that I added the mysql-connecter.jar to libraries.
Thank you
答案1
得分: 0
请使用以下内容生成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
英文:
Please use the following to generate jar file:
<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>
then run mvn clean package
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论