Kishirada
Kishirada

Reputation: 152

java - maven - Force inclusion of JDBC4 in JAR

I get a java.lang.NoClassDefFoundError: com/mysql/jdbc/exceptions/jdbc4/CommunicationsException whenever I try to launch my application as a jar, It does not occur while launching my application from IntelliJ.

Thus I conclude this issue to being JAR Only as it works when I use it from IntelliJ, but not when I use it from the JAR.

In my pom.xml

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.40</version>
</dependency>

Basically I have everything working except when I switch over to a JAR. I think this is caused by the JAR not having access to JDBC4 how do I force the inclusion of this in the JAR?

I've tried the following solutions aswell NONE OF THEM HAVE WORKED:

Error trying to import oracle jdbc7 driver with Maven

Find Oracle JDBC driver in Maven repository

Maven ojdbc configuration error

Maven - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

"com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure" to remote database

Upvotes: 0

Views: 339

Answers (1)

duffymo
duffymo

Reputation: 308753

Oracle has nothing to with it. You're using MySQL.

I think the problem is that your executable JAR does not have access to the dependencies.

Research how to create an executable JAR with dependencies using a Maven plugin.

Upvotes: 1

Related Questions