![](/img/trans.png)
[英]Cannot build a scala program “sbt package” failed with Exception in thread “main” java.sql.SQLException: No suitable driver
[英]Scala Error: java.sql.SQLException: No suitable driver found for jdbc:calcite:
我使用maven-assembly-plugin
創建了一個Scala應用程序的jar。 現在,當我使用java -jar path\\to\\jar\\myapp.jar
執行jar時,將引發以下錯誤:
Exception in thread "main" Exception in thread "Timer-0" java.lang.RuntimeException: java.sql.SQLException: No suitable driver found for jdbc:calcite:
at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:159)
at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:114)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:calcite:
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:153)
... 17 more
java.lang.RuntimeException: java.sql.SQLException: No suitable driver found for jdbc:calcite:
at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:159)
at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:114)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:calcite:
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:153)
... 8 more
當我通過IDE(IntelliJ)運行應用程序時,它運行良好。
誰能告訴我為什么會這樣嗎?
EDIT1:我打開了jar文件,並看到org/apache/calcite
calcite jar中存在calcite-core
jar。
EDIT2:我嘗試更改calcite-core
的版本。 我之前使用的是1.15.0
,現在使用的是1.18.0
但錯誤仍然存在。
似乎Apache Flink中存在錯誤-https: //issues.apache.org/jira/browse/FLINK-4581
盡管我仍然沒有找到calcite-core
驅動程序問題的解決方案,但我設法找到了另一種執行jar的方法。
我在pom.xml
添加了以下兩個插件。 maven-dependency-plugin
所有相關的依賴罐復制到lib
文件夾中,而maven-jar-plugin
制作一個可執行的jar文件。
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
</configuration>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.example.MainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
注意:添加<mainClass>com.example.MainClass</mainClass>
將使manifest.mf
知道主類是什么。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.