I'm building up a Maven Java 1.8 project in which I've included the MySQL Connector as a dependency:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
In my application I've a singleton that holds the MySQL connection so when the application starts, the MySQL connector is triggered but I got a ClassNotFoundException for the driver that I'm using: com.mysql.cj.jdbc.Driver.
The JDBC URL that I'm using is:
jdbc:mysql://localhost:3306/mydb?autoReconnect=true&useSSL=false
I'm using IntelliJ IDEA (2017.2) IDE.
I've checked in File -> Project Structure -> Libraries -> I see "Maven: mysql:mysql-connector-java:5.1.392" as a Library.
I've also checked under File -> Project Structure -> Artifacts -> and under myapp.war exploded -> WEB-INF -> lib -> Maven: mysql:mysql-connector-java:5.1.39 is present.
From View -> Tool Windows -> Database, I've succesfully made a MySQL connection dowloading the suggested driver (MySQL Connector 5.1.35).
How can I tell the application that it has to load the MySQL driver at runtime?
Thanks in advance