java.lang.ClassNotFoundException: org.sqlite.JDBC IntelliJ + Maven
I'm trying to connect my java application to my sqlite database but I'm getting this good old error. I'm using Maven and my setup looks like this:

I'm using IntelliJ and as far as I know Maven is well integrated. I'd like to know If I need to add the library somewhere else or put the jar file on the classpath.
I also leave here my pom.xml file with project definitions
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.16.1</version>
</dependency>
</dependencies>
</project>
This is my connection class:
package database;
import java.io.File;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**
* Created by luiscosta on 3/29/17.
*/
public class DBConnection {
private Connection conn;
private String dbPath;
/**
* Constructor
*/
public DBConnection(String name, String folder) throws FileNotFoundException {
File dbDir = new File(folder);
if (dbDir.isDirectory() && dbDir.exists()) { //confirms the database directory exists
if (folder.charAt(folder.length() - 1) == '/') { //checks if the directory ends in /
this.dbPath = folder + name;
} else {
this.dbPath = folder + '/' + name; //if not adds it in the end of the folder pah
}
//Connection
try {
Class.forName("org.sqlite.JDBC");
System.out.println("db Path" + this.dbPath);
this.conn = DriverManager.getConnection("jdbc:sqlite:ChunkMetaData");
} catch (Exception e) {
e.printStackTrace();
}
} else {
throw new FileNotFoundException("Directory not found!");
}
}
}
I've been looking for a solution for far too long and this is really slowing me down. I don't get how this is happening when I've followed every tutorial you suggested for this kind of installation.
I'd really appreciate any help
Kind regards
请先登录再写评论。
Please share the complete project that doesn't work for you: https://intellij-support.jetbrains.com/hc/articles/206869619.
I sent an email, but this is urgent . I leave here the link for the files/classes that are needed to have a runnable example.
https://gist.github.com/anonymous/aa9c78b733269eba8614a406268e9293
and Github
https://github.com/luistelmocosta/SDIS-FEUP
Regards
It's not the MCVE. Please share the complete project directory with .idea subdirectory and run/debug configuration you are using.