最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - JAR cannot find a suitable driver for SQLite JDBC connection even though it is in the classpath - Stack Overflow

programmeradmin1浏览0评论

Let me begin by saying that I've gone through half a dozen questions with the same subject and through the answers that tell to add SQLite JDBC driver to the pom.xml file. My case is different, because the dependency is already there and has always been, since the creation of the project. It runs in Netbeans but does not run on the command line.

Here's my pom. I removed other dependencies that have no bearing on the question and left only Xerial:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=".0.0" xmlns:xsi="; xsi:schemaLocation=".0.0 .0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.my</groupId>
    <artifactId>myproj</artifactId>
    <version>1.0-0</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.my.myproj.myclass</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mavenpiler.source>11</mavenpiler.source>
        <mavenpiler.target>11</mavenpiler.target>
        <exec.mainClass>com.my.myproj.myclass</exec.mainClass>
    </properties>
    <dependencies>
        <dependency>
          <groupId>.xerial</groupId>
          <artifactId>sqlite-jdbc</artifactId>
          <version>3.46.0.1</version>
        </dependency>
    </dependencies>
    <name>myproj</name>
    <description>myproj is</description>
</project>

Here's my manifest. I also removed the irrelevant dependencies from the classpath:

Created-By: Maven JAR Plugin 3.3.0
Build-Jdk-Spec: 11
Class-Path: <some jars> sqlite-jdbc-3.46.0.1.jar slf4j-api-1.7.36.jar <more jars>
Main-Class: com.my.myproj.mymainclass

I do notice that slf4j is in the classpath but not in pom.xml but this should not be a problem, should it? If it's on the classpath, that should suffice, should it not?

What is still missing for this JAR to be self-contained and run on the command line?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论