This question has asked many times, but this one is slightly different. In my case, I'm not getting any error when running from Eclipse, it successfully runs and is able to connect to MySQL.
I have a Maven project in Eclipse, using the MySQL database and MySQL Connector/J for connection.
However, after deploying to jar I am getting the error.
I am using mvn clean install
to deploy
I have added dependency in pom.xml like:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
<scope>runtime</scope>
</dependency>
I am using following command to run the jar file
java -jar ./target/project.jar
but this gives
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
What's wrong here?